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

geopackage bounding box search using rtreeindex #9

Open
rghosh0 opened this issue Apr 25, 2017 · 0 comments
Open

geopackage bounding box search using rtreeindex #9

rghosh0 opened this issue Apr 25, 2017 · 0 comments

Comments

@rghosh0
Copy link
Contributor

rghosh0 commented Apr 25, 2017

Make a method that uses this logic to create and return an array of MaplyVectorObjects, given a GPKGGeoPackage object, a bounding box, and a table name.

Make a class for this purpose. GPKGFeatureSource

Use this logic:

 MaplyBoundingBox geoBboxDeg /* = ... */ ;
    GPKGGeoPackage *geoPackage /* = ... */ ;
    GPKGFeatureDao *featureDao = [geoPackage getFeatureDaoWithTableName:tableName];
    GPKGRTreeIndex *rtreeIndex = [[GPKGRTreeIndex alloc] initWithGeoPackage:geoPackage andFeatureDao:featureDao];;
    GPKGResultSet * geometryIndexResults = [rtreeIndex queryWithBoundingBox:[[GPKGBoundingBox alloc]
                                                                              initWithMinLongitudeDouble:geoBboxDeg.ll.x
                                                                              andMaxLongitudeDouble:geoBboxDeg.ur.x
                                                                              andMinLatitudeDouble:geoBboxDeg.ll.y
                                                                              andMaxLatitudeDouble:geoBboxDeg.ur.y]];
    GPKGRTreeIndexResults *featureIndexResults = [[GPKGRTreeIndexResults alloc] initWithRTreeIndex:rtreeIndex andResults:geometryIndexResults];
    GPKGResultSet *results = [featureIndexResults getResults];

    while([results moveToNext]) {
        GPKGFeatureRow *row = [rtreeIndex getFeatureRowWithResultSet:results];
        GPKGGeometryData *geometryData = [row getGeometry];
        if(geometryData != nil && !geometryData.empty) {
                
            WKBGeometry * geometry = geometryData.geometry;
            if(geometry != nil) {
                if (geometry.geometryType == WKB_LINESTRING) {
                    WKBLineString *lineString = (WKBLineString *)geometry;
                    // ...
                } /* else if ... */
            }
        }
    }

And use code similar to GPGKFeatureTileSource buildObjectsWithTileID:andGeoBBox:andGeoBBoxDeg:andCompObjs: to create the vector objects, with the appropriate attributes.

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

1 participant