Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

intersection function doesn't work #5

Open
luis901101 opened this issue Jun 20, 2018 · 11 comments
Open

intersection function doesn't work #5

luis901101 opened this issue Jun 20, 2018 · 11 comments

Comments

@luis901101
Copy link

The intersection function doesn't return anything when intersecting two MULTILINESTRING, however the spatialite_gui application do returns. I've tested the same query with the same database and the intersection with android-spatialite doesn't show anything even when there are multiple rows as result.
This is my query, which returns 18 rows, but the column asd which represents the intersections as texts, only shows nulls

select name, astext(intersection(geometry, (select geometry from ln_data where name like '%desagü%'))) as asd
from ln_data
where
intersects(geometry, (select geometry from ln_data where name like '%desagü%'))

@sevar83
Copy link
Owner

sevar83 commented Jun 21, 2018 via email

@luis901101
Copy link
Author

  1. The intersects function does work, in fact the example query posted in the issue returns 18 rows.
  2. "umlaut" ??? don't understand what you mean??? if you are referring to the like '%desagü%' I tested with other conditions and the intersection function still doesn't work.

@sevar83
Copy link
Owner

sevar83 commented Jun 21, 2018 via email

@luis901101
Copy link
Author

What I need to do is a geocoding search using spatialite, that's why I need the intersection function, I made a small spatialite database for testing purposes, cause my app database is really big. This database has an only table with 18 rows representing streets, each row has a name and a MULTILINESTRING geometry.

Link to download database: https://mega.nz/#!BY8QEI5Z!FSW6rQkBHQk8LMnNq6ph5TwCN7sUJy0a6tEsqmzfO00

Running this query using spatialite_gui app:

select name, geometry, astext(geometry) textgeometry, astext(intersection(geometry, (select geometry
from ln_data where id=62175
))) as textintersection
from ln_data
where 
intersects(geometry, (select geometry
from ln_data where id=62175
))

will return 18 rows which are the intersections of the street with id=62175 and the rest of the streets in database including the same. In the spatialite_gui app this query results is OK, 18 rows and each column has a non null value as expected, but using android_spatialite the 18 rows has a null value in the conlumn of textintersection.

This is the java code I used:

SQLiteDatabase spatialiteDatabase = SQLiteDatabase.openDatabase("/sdcard/map/test.sqlite", null, SQLiteDatabase.OPEN_READONLY);

Cursor cursor = spatialiteDatabase.rawQuery("select name, geometry, astext(geometry) textgeometry, astext(intersection(geometry, (select geometry\n" + "from ln_data where id=62175\n" + "))) as textintersection\n" + "from ln_data\n" + "where \n" + "intersects(geometry, (select geometry\n" + "from ln_data where id=62175\n" + "))\n", null);

if(cursor != null && cursor.moveToFirst())
{
    do
    {
        String name = cursor.getString(cursor.getColumnIndex("name"));
        byte[] geometry = cursor.getBlob(cursor.getColumnIndex("geometry"));
        String textgeometry = cursor.getString(cursor.getColumnIndex("textgeometry"));
        String textintersection = cursor.getString(cursor.getColumnIndex("textintersection"));
        Log.d("test", "name: " + name);
        Log.d("test", "geometry: " + geometry);
        Log.d("test", "textgeometry: " + textgeometry);
        Log.d("test", "textintersection: " + textintersection);
    }while(cursor.moveToNext());
}

spatialiteDatabase.close();

So this query uses 3 spatialite functions which are: astext(...), intersection(...) and intersects(...), and I have 18 rows as result, so the intersects(...) function is working OK, and the astext(...) function is working OK, but the intersection(...) function is not working at all.

I hope this is enough to reproduce the problem I've been facing.

Thanks in advance.

@sevar83
Copy link
Owner

sevar83 commented Jun 22, 2018 via email

@luis901101
Copy link
Author

I checked and the Spatialite version is the same, the GEOS version it is different, it is the v3.5.0 different to the v3.4.2 included in the lib... But i don't think the problem is a missing function cause there is not any Sqlite Exception about any invalid function...

@sevar83
Copy link
Owner

sevar83 commented Jun 24, 2018 via email

@luis901101
Copy link
Author

Ok thanks, I will be aware.

@yuechaoyue666
Copy link

Is this problem solved?

@luis901101
Copy link
Author

Is this problem solved?

No idea, it has been a long time

@yuechaoyue666
Copy link

Is it possible that intersects=1 but intersection=null?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants