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

Question: Non-Geospatial Maps & SRIDs? #730

Closed jmandel1027 closed 3 years ago

jmandel1027 commented 3 years ago

Hi there!

I had a question about non-geospatial maps, my company has been super impressed w/ Tegola and we think it might fit perfectly into our use-case.

We have a pipeline to convert Blueprints(CAD/PDF) into Raster Tiles & Vectorized data and we're in need of a tile server! Our data is stored in PostGIS in vanilla cartesian coordinates (x, y, WKBs, POLYLINE etc) that don't require projections, in other words SRID 0. Can Tegola support Raster (& vector tiles eventually) that don't require geo-projections like Web-Mercator EPSG 3857 or EPSG 4326?

If you guys can't support it at the moment, totally happy to jam w/ the maintainers to come up w/ a reasonable solution and open a PR. We love Tegola and would be awesome to use it for our problem.

Thanks!

ARolek commented 3 years ago

@jay-manday I'm glad you're enjoying tegola! I have not attempted to use vector tiles with data without a SRID, but it might be possible. Are you using ST_AsMVT for generating the vector tiles in PostGIS? If not, that would be the first place I would attempt this. Here's an example provider config block to take advantage of SA_AsMVT:

[[providers]]
name = "cities"
type = "mvt_postgis"
host = "${DB_HOST}"
port = 5432
database = "${DB_NAME}"
user = "${DB_USER}"
password = "${DB_PW}"

    [[providers.layers]]
    name = "cities"
    geometry_type = "polygon"
    geometry_fieldname = "geom"
    id_fieldname = "id"
    sql = "SELECT id, name, ST_AsMVTGeom(geom_3857, !BBOX!) AS geom FROM gis.places WHERE geom_3857 && !BBOX!"

I think the crux of this request comes down to informing the reprojection routine to convert between the coordinate space of your blueprints to tile coordinates. I'm not sure if this will work with SRID=0, but I'm sure we can figure out a way to get make it work.

I'm interested in how this comes together, so please keep me in the loop!

jmandel1027 commented 3 years ago

Hey Alex,

Thanks for following up on this, and for the pointer as well! Using ST_AsMVTGeom is definitely the ideal situation, we're currently extracting vector & raster data generation during the ingestion of PDFs. Per page we'll use OGR2OGR to extract the data inside the and store in our blueprint table.

For the raster side we currently generate PNGs but very very soon we're going to expand the pipeline w/ either imagemagick or libvps to rasterize the PDF Page and generate a tileset, (other ideas in the GDAL sphere are on the table). The intermediary stop gap is to host the Raster Tiles in S3, but having Tegola as our Raster & Vector Tileserver is the preferred solution in the long run.

We need to be able to support both Raster & Vector Tiles, because we need to do some sort of staging to see if that page within the plans has any valid vector data. Theres a many different types of PDF drivers out there so we need to make a decision if we think the page has valid geometries. If it does, generate the vector tiles, if not, defer to the raster tiles. Ideally we'd like Tegola to support both types, Raster & Vector because going back and forth between S3 on a given Tileset is going to be very inefficient

If you have any suggestions for handling Raster Tiles w/ Tegola that will deff be appreciated as well!

And Re: In the loop. Certainly! We're going to move on this in the first weeks of the new year so we'll deff keep you posted, more likely than not I'm going to come back here w/ Q's 😆

Thanks again!

-J

ARolek commented 3 years ago

@jay-manday apologies for the slow response. I decided to stack the end of 2020 with moving to a different state and I'm still working on unboxing my life.

Regarding tegola handling raster tiles, I don't foresee tegola tackling raster tiles in the near future. Currently, tegola is responsible for generating the vector tiles and the rendering happens client-side. In order for tegola to generate raster tiles we would need to implement the Mapbox style spec in tegola. An alternative approach we have played with is to use Mapbox GL as a proxy between tegola and a raster tile request. We have a POC of some Go bindings to Mapbox GL Native at https://github.com/go-spatial/go-mbgl. The big benefit to this approach is that you can use the same Mapbox style sheet for client rendering and the proxy. Unfortunately, we have not made many updates to that project, but if you're interested in the approach I can try to answer some questions around it.

jrutila commented 3 years ago

@jay-manday any news on getting tegola to work with SRID 0?

ARolek commented 3 years ago

@jrutila did you give the suggestion I posted a try?

jrutila commented 3 years ago

Actually, I think Tegola is working out of the box as long as I have the data in PostGIS with SRID 0. I just don't set srid in tegola config and it runs the coordinates through as is thus serving the vectors correctly.

ARolek commented 3 years ago

@jrutila great! I'm going to close this issue for now.

jmandel1027 commented 2 years ago

@jrutila @ARolek hey! sorry for the delayed response. Kind of got swept away with things.

We actually went a different route. We couldn't always guarantee a perfectly vectorized blueprint page so we opted for a tile pyramid scheme in S3 which we rendered w/ Deck.GL. I thiiiink it's possible to change the SRIDs w/ Tegola but I didn't get that far w/ it before hitting a wall w/ shakey vectorization problems.

ARolek commented 2 years ago

@jay-manday thanks for the follow-up, and I'm glad you found a solution.