go-spatial / tegola

Tegola is a Mapbox Vector Tile server written in Go
http://tegola.io/
MIT License
1.28k stars 194 forks source link

[dataprovider/geopackage] Unknown Geometry Type 12 error (support for extended types) #764

Open donnyv opened 3 years ago

donnyv commented 3 years ago

So I exported a parcels layer from a file geodatabase to a geopackage. I then added add the geopackage to the config. I get this when I try to pan or zoom. image

When I look at the geopackage in QGIS. This is the info I get. Where am I going wrong? image

donnyv commented 3 years ago

So I took the geopackage parcels and turned it into lines and then turned lines into polygons and still get the same error message. All done in QGIS.

ARolek commented 3 years ago

@donnyv that sounds like a decoding error so I suspect it has to do with the WKB data in the geopackage. For reference the Gpkg Geometry Encoding spec can be found here. Looking at the spec I'm not quite sure where the issue could be but maybe you're encountering a GeometryCollection type. Can you run the following query on your GeoPackage and post the output:

SELECT * FROM gpkg_geometry_columns
donnyv commented 3 years ago

I get this image

ARolek commented 3 years ago

@donnyv it appears you have 2 data providers though, the parcels and the PhotoPoints. can you provide the query for the other dataset?

donnyv commented 3 years ago

I did but I removed it to narrow down what the error is. This is the current config settings.

[webserver]
port = ":9090"              # port to bind the web server to. defaults ":8080"

    [webserver.headers]
    Access-Control-Allow-Origin = "*"
    Cache-Control = "no-cache, no-store, must-revalidate"

#[cache]                     # configure a tile cache
#type = "file"               # a file cache will cache to the local file system
#basepath = "cache"         # where to write the file cache

[[providers]]
name = "SussexParcelsGeoPkg"
type = "gpkg"
filepath = "SussexParcels.gpkg"

    [[providers.layers]]
    name = "parcels"
    tablename = "SussexParcels"
    id_fieldname = "fid"

# maps are made up of layers
[[maps]]
name = "sussexcounty"                  # used in the URL to reference this map (/maps/zoning)

    [[maps.layers]]
    name = "parcels"
    provider_layer = "SussexParcelsGeoPkg.parcels" 
donnyv commented 3 years ago

Data is here: http://gis.civilsolutions.biz/downloads/SussexParcels.7z

ARolek commented 3 years ago

@donnyv that link is not downloading for me. Is this by chance the same data? https://data-1-sussex.opendata.arcgis.com/datasets/sussex-county-tax-parcel-features/data?geometry=-76.086%2C40.947%2C-73.274%2C41.309

ARolek commented 3 years ago

I was able to pull the data from the link I posted down as a GeoDatabase -> QGIS -> Save layer as GeoPackage, the run tegola against it fine. I left my data in 4326 though, but I don't think that should matter in this instance:

Screen Shot 2021-03-29 at 4 30 30 PM

I'm running on MacOS, but again, I don't think that should make a difference regarding the error you're seeing.

donnyv commented 3 years ago

Thats not where I got the data. Copy and paste that link in a new tab.

ARolek commented 3 years ago

Ok I think I have tracked down your issue. It appears that the geometry is encoded as a MULTISURFACE type, rather than a MULTIPOLYGON. You can see this in the Geopackage Geometry Types table definition. Tegola uses a geometry package for WKB decoding that only has support for the core types, not the extended types. The geometry package is being extended to support more types but I'm not sure when this will be complete. It appears that these extended types are synonymous but I need to investigate some more.

In the near term, I think we need to look for a way to get QGIS to output the type correctly. I don't think these geometries need to be defined as MULTISURFACE but rather MULTIPOLYGON.

donnyv commented 3 years ago

Good to know. You should put that in the Read Me on GitHub, so people don't bother you about geometry issues.

How did you find that it was a Multisurface? When I looked in DB SQL Viewer and QGIS, it said it was Multipolygon. If I can detect it maybe I can convert it to a Multipolygon.

Thanks so much for looking into this.

ARolek commented 3 years ago

@donnyv this is actually the first time I have encountered this issue. The WKB specification does not have these extended types. PostGIS also has an extended version of WKB called EWKB which supports additional geometry attributes.

How did you find that it was a Multisurface?

Since the decoder was reporting unknown geometry 12, I cross-referenced that with the Geometry Types table from the GeoPackage spec.

@gdey it looks like we now have 2 different extensions of WKB: EWKB (currently being worked on in #449) and the GeoPackage types. Just something to consider as geom package's wkb handling evolves, we will likely need some separate packages that extend WKB in different ways.