queryForGeoJSONFeaturesInTable throws an error for some geopackage files
See original GitHub issueVersion: 2.1.0
First of all, thanks for this comprehensive geopackage library!
I recently ran into a problem with some geopackage files. Calling queryForGeoJSONFeaturesInTable
results in the following error:
Uncaught (in promise) TypeError: Cannot read property 'x' of null
at geocentricToGeodetic (geopackage.js:58208)
at datum_transform (geopackage.js:58393)
at transform (geopackage.js:58506)
at transformer (geopackage.js:58545)
at proj4$1 (geopackage.js:58584)
at BoundingBox.projectBoundingBox (geopackage.js:1264)
at FeatureTableIndex.queryWithBoundingBox (geopackage.js:5724)
at FeatureDao.queryForGeoJSONIndexedFeaturesWithBoundingBox (geopackage.js:13493)
at module.exports.GeoPackage.queryForGeoJSONFeaturesInTable (geopackage.js:14250)
at resolver (GeoPackageLoader.js:94)
The issue is, that point ends up being null in geocentricToGeodetic
.
The point becomes null during datum_transform
after calling geodeticToGeocentric
.
And the reason is because the latitude is not in polar coordinates:
This is the location in my code where the error occurs: https://github.com/potree/potree/blob/72748db38fd46a98c4d0800a70b1fe2570365152/src/loader/GeoPackageLoader.js#L92
Note that this looks a bit different than the official examples and the GeoPackage Viewer, because the version: 2.1.0 release seems to have a different API (no getFeatureRow() function, for example). What I’d like to accomplish is to load 3D data of all stored features, so that I can create 3D models out of them.
Here is an example that works: 3D Scene: http://mschuetz.potree.org/geopackage/examples/geopackage.html Geopackage file: http://mschuetz.potree.org/geopackage/examples/morro_bay_shp/gpkg/geopackage.gpkg
And this is the geopackage that causes an error when loading with geopackage-js: 3D Scene: http://mschuetz.potree.org/geopackage/not_working/gpgp.html Geopackage file: http://mschuetz.potree.org/geopackage/not_working/test2d_potree17_epsg2056.gpkg
Help on how to fix this issue or on how to correctly load 3D geometry data for features would be highly appreciated. Thanks!
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
I will check into this and get back to you soon.
To create the proj4js projection, we will pass the WKT defined in the definition column of the gpkg_spatial_ref_sys table to proj4. Except in the case of 4326. So, it appears that the issue is, the definition in your GeoPackage is:
PROJCS["CH1903+ / LV95",GEOGCS["CH1903+",DATUM["CH1903+",SPHEROID["Bessel 1841",6377397.155,299.1528128,AUTHORITY["EPSG","7004"]],TOWGS84[674.374,15.056,405.346,0,0,0,0],AUTHORITY["EPSG","6150"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4150"]],PROJECTION["Hotine_Oblique_Mercator_Azimuth_Center"],PARAMETER["latitude_of_center",46.95240555555556],PARAMETER["longitude_of_center",7.439583333333333],PARAMETER["azimuth",90],PARAMETER["rectified_grid_angle",90],PARAMETER["scale_factor",1],PARAMETER["false_easting",2600000],PARAMETER["false_northing",1200000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","2056"]]
which is very slightly different from (https://spatialreference.org/ref/epsg/ch1903-lv95/ogcwkt/):PROJCS["CH1903+ / LV95",GEOGCS["CH1903+",DATUM["CH1903",SPHEROID["Bessel 1841",6377397.155,299.1528128,AUTHORITY["EPSG","7004"]],TOWGS84[674.374,15.056,405.346,0,0,0,0],AUTHORITY["EPSG","6150"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4150"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Hotine_Oblique_Mercator"],PARAMETER["latitude_of_center",46.95240555555556],PARAMETER["longitude_of_center",7.439583333333333],PARAMETER["azimuth",90],PARAMETER["rectified_grid_angle",90],PARAMETER["scale_factor",1],PARAMETER["false_easting",2600000],PARAMETER["false_northing",1200000],AUTHORITY["EPSG","2056"],AXIS["Y",EAST],AXIS["X",NORTH]]
When I modify your GeoPackage file and change the definition in the srs table to the above, the features are drawn in the correct location.