6

I've created a network topology using QGIS, saved it as a shp, imported it into PostGIS using shp2pgsql and I'm now trying to output some of the geometry using mapserver.

Unfortunately mapserver is kicking up the following error:

msDrawMap(): Image handling error. Failed to draw layer named 'ROUTE'. msPostGISLayerWhichShapes(): Query error. Error (ERROR: Operation on two geometries with different SRIDs ) executing query: select encode(AsBinary(force_collection(force_2d("the_geom")),'NDR'),'hex') as geom,"gid" from (SELECT buildingroute.the_geom,buildingroute.gid FROM routetest INNER JOIN buildingroute ON routetest.toid=buildingroute.gid ORDER BY routetest.id ASC) AS foo where the_geom && GeomFromText('POLYGON((-22000000 -11000000,-22000000 11000000,22000000 11000000,22000000 -11000000,-22000000 -11000000))',32709)

Now I don't know a lot about spatial referencing, but I've copied the settings from QGIS and I still get those errors. Here's those settings in QGIS: enter image description here

The mapserver file I created can be found at http://pastie.org/2202322

If anyone can give me advice on what I need to change in the mapserver file I'd appreciate it.. I expect I've just got the projection settings wrong..

Thanks!

RichW
  • 511
  • 3
  • 11
  • 2
    To be sure of your projection, you should check your tables srid : SELECT srid(the_geom) FROM "routetest" LIMIT 1 and SELECT srid(the_geom) FROM "buildingroute" LIMIT 1 – simo Jul 12 '11 at 16:13
  • 1
    Unless you explicitly set the SRID during conversion in shp2pgsql, I think it defaults to -1, which is the "unknown" projection. – MerseyViking Jul 12 '11 at 16:34
  • Excellent point.. I tried those queries and it reported that the SRID was -1. I used MerseyViking's technique to change the SRID and that fixed that issue. Thanks! – RichW Jul 15 '11 at 10:10

1 Answers1

6

In your map file try changing the map's projection to read from the epsg file. Your current map projection isn't a full projection description.

So rather than:

MAP
    NAME TEST
    STATUS ON
    IMAGECOLOR 255 255 255
    IMAGETYPE PNG
    PROJECTION
      "proj=utm"
      "ellps=WGS84"
      "datum=WGS84"
    END

Use:

MAP
    NAME TEST
    STATUS ON
    IMAGECOLOR 255 255 255
    IMAGETYPE PNG
    PROJECTION
      "init=epsg:32709"
    END

Or put in the full projection description of:

PROJECTION
  "proj=utm"
  "ellps=WGS84"
  "datum=WGS84"
  "zone=9"
  "units=m"
  "south"
  "no_defs"
END

As your layer is in the same projection as the map you can remove the projection from the layer definition - it is assumed to be in the map projeciton unless specified otherwise.

   PROJECTION
      "init=epsg:32709"
   END
geographika
  • 14,320
  • 4
  • 53
  • 77
  • Along with having the wrong projection in the database this did the trick nicely. Thanks! I really need to learn more about mapserver as it seems very powerful - unfortunately I'm quite new to GIS and projections though so it seems like quite a steep learning curve. – RichW Jul 15 '11 at 10:12