ngageoint / geopackage-js

GeoPackage JavaScript Library
http://ngageoint.github.io/geopackage-js/
MIT License
304 stars 78 forks source link

Set GeoJson id from id property #176

Closed juancromero-cotesa closed 2 years ago

juancromero-cotesa commented 2 years ago

In the iterable of the queryForGeoJSONIndexedFeaturesWithBoundingBox method of FeatureDao the id property is ignored when it arrives in the feature from the Geopackage. Only '_feature_id' is taken into account i propose this

for (var key in featureRow.values) {
   if (Object.prototype.hasOwnProperty.call(featureRow.values, key) &&
                                    key !== featureRow.geometryColumn.name ) {
                                      if (key.toLowerCase() === 'id' || key.toLowerCase() === '_feature_id') {
                                        geoJson.id = featureRow.values[key];
                                    }
                                    else if (key.toLowerCase() === '_properties_id') {
                                        geoJson.properties[key.substring(12)] = featureRow.values[key];
                                    }
                                    else {
                                        geoJson.properties[columnMap[key].displayName] = featureRow.values[key];
                                    }
                                }
                            }
juancromero-cotesa commented 2 years ago

Opened a pull request to set the id property into the GeoJson properties object to not loose feature id value