question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

queryForGeoJSONFeaturesInTable throws an error for some geopackage files

See original GitHub issue

Version: 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. image

The point becomes null during datum_transform after calling geodeticToGeocentric. image

And the reason is because the latitude is not in polar coordinates: image

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:open
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
danielbarelacommented, Jan 14, 2020

I will check into this and get back to you soon.

0reactions
danielbarelacommented, Jan 16, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

QGIS 2.14.9 refuses to open GeoPackage file
I tried to open in QGIS 2.14.9 a .gpkg file but this action resulted in an error message stating that the file is...
Read more >
Convert Data to GeoJSON in a JavaScript App - Sparkgeo
Here, I demonstrate a tool that converts some geospatial formats to GeoJSON ... GeoPackage is an OGC committee-built file format for sharing ...
Read more >
Error reading geopackage - FME Community - Safe Software
This causes some issues. However, renaming the tables and layer data does not resolve the FME errors upon opening this file.
Read more >
Getting Started With GeoPackage
A GeoPackage is an SQLite Database file with a .gpkg extension. ... or from an existing source file such as a ShapeFile or...
Read more >
GDAL/ogr2ogr File Conversion - General Usage
using GDAL using SQLite GDAL.ogr2ogr_path() do ogr2ogr run('$ogr2ogr -f GPKG output.gpkg input.shp') end. Which throws an error: ERROR: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found