center map on x,y coordinates

Jan Hartmann j.l.h.hartmann at UVA.NL
Sat Oct 2 09:06:40 EDT 2004


Elisabeth,

There are several reasons why this MapFile cannot work with this URL:

- The layer's STATUS is ON, which means that it has to be added to the
URL to be visible ("http:?/..&layer=strasse). Only layers with STATUS
DEFAULT are always displayed.

- the EXTENT is wrong. EXTENT should be set as "x1 y1 x2 y2", where x2
and y2 are both higher than x1/y1. Your y2 is smaller than y1.

- the MAPXY parameter seems to have switched x/y compared with the EXTENT.

- You give a scale of 20000 in the URL, but you limit the layer between
scales 500 and 1000. This means the layer will not be displayed.

- The expression in the CLASS statement will only select streets with an
ID of exactly *one* letter. If you want to select all streets, the
expression has to be /.*/

- Are you sure your streets are polygons?

Perhaps you could start with a rudimentary MapFile: set STATUS DEFAULT,
comment out MAXSCALE and MINSCALE and set the CLASS expression to /.*/.
Then call this with only "map=map.map&mode=map" in the URL. If you still
don't see anything, check if the extent of the vector file matches that
of the MapFile and if its type is polygon. (e.g. by using ogrinfo). Also
try giving the complete path to the shapefile (as specified here it
should be: /..../cgi-bin/data/vector/strasse.shp).

As soon as you can see a picture of the whole map, you can try to center
it on a given coordinate. My way would be to recompute the extent. Say,
you want a map centered around 1500/337000. A 200*200m map around this
point can ge generated by an extent of 1400 336900 1600 337100. In my
experience this is much easier to compute than MAPXY and SCALE.

Hope this helps,

Jan

Elisabeth Nolz wrote:

> hi list.
>
> i posted this problem months ago, and altough i got lots of answers (thanx to
> all) i couldn't solve it. but now i need this function again and have to get
> it working as soon as possible.
>
> i want to center my map on x,y coordinates. this is the link i use:
> http://localhost/cgi-bin/mapserv?map=map.map&mode=map&mapxy=339989.20+1646.20&scale=20000
>
> i can see the background-color of the map, but nothing else. here's an
> abstract of my mapfile:
> NAME TEST
> STATUS ON
> SIZE 400 300
> EXTENT 1150 340000 1900 339550
> UNITS meters
> SHAPEPATH "data"
> IMAGECOLOR 230 230 230
> IMAGETYPE GIF
>
> LAYER
>   NAME "strasse"
>   GROUP "Eintausend"
>   METADATA
>     LYRNAME  "Strasse"
>   END
>   MINSCALE 500
>   MAXSCALE 1000
>   DATA "vektor/strasse"
>   STATUS ON
>   TYPE POLYGON
>   CLASSITEM "ID"
>   CLASS
>     NAME "Strasse"
>     EXPRESSION /./
>     OUTLINECOLOR 0 0 0
> #    COLOR 0 0 0
>   END
> END
>
> please, can someone figure out whats going wrong?
> thx,
> elisabeth.
>



More information about the mapserver-users mailing list