rurseekatze / node-tileserver

A lightweight tileserver based on NodeJS for serving bitmap and vector tiles.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

query err: error: Operation on mixed SRID geometries

adibarda opened this issue · comments

Hello,
I'm getting mixed SRID geometries error in funcion: getDatabaseQuery: function(bbox) in tile.js
Do you have any idea why?

this is the generated query:

SELECT ST_AsGeoJSON(ST_TransScale(ST_ForceRHR(ST_Intersection(way, ST_SetSRID('BOX3D(3889115.9991497695 3769262.7387969648,3890338.9916023314 3770485.731249527)'::box3d, 900913))), 
                        -3889115.9991497695, -3769262.7387969648, 8.176665341681026, 8.176665341677914), 0) AS way,
hstore2json(CAST(hstore(tags) AS hstore)) AS tags,
ST_AsGeoJSON(ST_TransScale(ST_ForceRHR(ST_PointOnSurface(way)), -3889115.9991497695, -3769262.7387969648, 8.176665341681026, 8.176665341677914), 0) AS reprpoint    

FROM (  SELECT (ST_Dump(ST_Multi(ST_SimplifyPreserveTopology(ST_Buffer(way ,-8.59916568208233), 8.59916568208233)))).geom AS way, 
        tags
        FROM  ( SELECT ST_Union(way) AS way, tags                                       
                FROM (  SELECT ST_Buffer(way, 8.59916568208233) AS way, 
                CAST(tags AS text) AS tags  
                FROM planet_osm_polygon 
                WHERE way && ST_SetSRID('BOX3D(3889115.9991497695 3769262.7387969648,3890338.9916023314 3770485.731249527)'::box3d, 900913) AND way_area > 41.08091690439025 AND (tags->'usage'='main') ) p
                GROUP BY CAST(tags AS text) ) p                         
                WHERE ST_Area(way) > 73.94565042790245
                ORDER BY ST_Area(way)) p                        

UNION       

SELECT  ST_AsGeoJSON(ST_TransScale(ST_Intersection(way, ST_SetSRID('BOX3D(3889115.9991497695 3769262.7387969648,3890338.9916023314 3770485.731249527)'::box3d, 900913)), -3889115.9991497695, -3769262.7387969648, 8.176665341681026, 8.176665341677914), 0) AS way,
hstore2json(CAST(hstore(tags) AS hstore)) as tags,
Null AS reprpoint                       
FROM ( SELECT (ST_Dump(ST_Multi(ST_SimplifyPreserveTopology(ST_LineMerge(way), 8.59916568208233)))).geom AS way, 
        tags 
        FROM ( SELECT ST_Union(way) AS way, 
        CAST(tags AS text)  
        FROM planet_osm_line 
        WHERE way && ST_SetSRID('BOX3D(3889115.9991497695 3769262.7387969648,3890338.9916023314 3770485.731249527)'::box3d, 900913) AND 
        (tags->'usage'='main')  GROUP BY CAST(tags AS text) ) p ) p                     


UNION 

SELECT ST_AsGeoJSON(ST_TransScale(way, -3889115.9991497695, -3769262.7387969648, 8.176665341681026, 8.176665341677914), 0) AS way,                      
             hstore2json(tags) AS tags,                 
             Null AS reprpoint                      
             FROM planet_osm_point                      
             WHERE  way && ST_SetSRID('BOX3D(3888829.3602937004 3768976.0999408956,3890625.6304584006 3770772.3701055963)'::box3d, 900913) AND (tags->'usage'='main') LIMIT 10000

Thank you very much for your help,
Adi Barda

This error might be happening because osm2pgsql uses EPSG:3857 (--merc option and default behaviour) for a longer time, but node-tileserver still used the deprecated EPSG:900913.

Now node-tileserver was updated so that it expects the geometries in the database stored as EPSG:3857. See #122 and #129 for further details.