[Mapserver-users] Re: Center in lat/lon, radius in miles?

Brian Fujito brian at christianity.com
Fri Aug 29 17:51:46 EDT 2003


Hi there, I saw your post from back in 2001:
http://mapserver.gis.umn.edu/data2/wilma/mapserver-users/0109/msg00064.html
I'm hoping that I can get some followup help on this.

I'm trying to do the same thing, where my map is in lcc, but I would
like to tell it, "center the map at longitude,latitude = x,y, and show
an X-mile radius around it".  I'd like for the image dimensions to
remain the same, and for the resulting image to remain in lcc as much as
possible.

Here is my mapfile:

########### begin mapfile 

NAME VA

# The following is the lcc extent (conic-projected)
#EXTENT -399619.932233 1844229.926521 396405.724268 2442378.083651

# The following is the latlong extent
EXTENT -84.109175 35.285090 -74.820374 40.660661

SIZE 360 270

SHAPEPATH /www/mysite.mysite.com/html/mapserver/data/
FONTSET /www/mysite.mysite.com/html/mapserver/fonts/fonts.list
IMAGECOLOR 178 210 225
#UNITS MILES

WEB
  TEMPLATE
/www/mysite.mysite.com/html/mapserver/templates/statetemplate_nav.html
  IMAGEPATH /www/mysite.mysite.com/html/mapserver/tmp/
  IMAGEURL /mapserver/tmp/
END

PROJECTION
#    "proj=lcc"
    "proj=latlong"
    "lat_0=20"
    "lat_1=60"
    "lon_0=-79.4460735"
END

LAYER
    NAME states
    STATUS DEFAULT
    DATA statesptrunc
    TYPE POLYGON
 
    PROJECTION
        "proj=latlong"
    END

    CLASS
	NAME "states"
	COLOR 213 213 213
	OUTLINECOLOR 130 130 130
    END

END #layer

END #mapfile

############## end mapfile

If I switch this mapfile to be in latlong (by changing comments at
EXTENT and PROJECTION), and pass the CGI:
  &mapxy=-77.051663+38.799917&buffer=.3
then it actually does the right thing... it zooms into the top right
area of the Viginia map.

However, with the mapfile as above, when I pass it:
  &mapxy=-77.051663+38.799917&buffer=.3
then it sends me off somewhere else.  My output template is set to
display some information including the extent, and it seems to be in
long/lat coordinates:  -80.000000 35.000000 -72.000000 41.000000 
This attempt was in hopes that the comment in the post that "If it's in
lat/lon MapServer will convert to the output projection before
continuing" meant that mapserver would convert my inputs to lcc, and
then do the rest appropriately, and return me an lcc map.

I then tried the alternative, where I computed the lcc-equivalent of 
my -77.051663,38.799917 point.  So, I ran:
  &mapxy=186521.66,4397421.94&buffer=.3
But then, that threw me way off, somewhere else.  It seemed that the
extent was still lcc, but it pushed me far off somewhere...

What am I doing wrong?  I would prefer to be able to pass it
longitude/latitude directly (and have lcc results).

Thank you very much, in advance, for your help!

Brian



  



>>>>>>

Are you using parameters like mapxy and buffer to do this or some other
method? Since your output map is lcc this isn't hard. You just need to
convert
your center point from lat/lon to lcc and then generate the exent around
that
computed point. The CGI program (compiled with Proj.4) has built-in
capabilities
to do this. For example, assuming a non-geographic output projection you
can
set mapext or mapxy in the output projection or in lat/lon. If it's in
lat/lon MapServer
will convert to the output projection before continuing. You can use the
buffer
parameter to specify a radius to use around the mapxy point. In your
case you'd
set it to ½ a mile (in output units).

Hope this helps.

Steve

Stephen Lime
Internet Applications Analyst

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937

>>> Bill Lubanovic <bill at madscheme.com> 09/06/01 04:36PM >>>

Although I've read the docs, installed the demo, and have built working
applications, I'm stuck on something that sounds simple.

I'm trying to plot a map with its center at a given lat/lon and a radius
of a given number of miles.   The map would actually be the bounding box
of this circle, not clipped to the circle.  And it would only be a
circle in lat/lon space (Mercator), not in any other projection, right?

The data files (state/county/etc. boundaries) are good, and the
projection from lat/lon to lcc and other projections works in the
template file.   But I'm not sure how to define the extent around the
centerpoint, since the original lat/lon (DD) space doesn't equate to
miles.  I'm approximating the bounding box by trial and error.  Should I
use proj.4 to calculate the extents in miles for each lat/lon
centerpoint?  Or is there a way in Mapserver to specify this directly?

Thanks,
Bill Lubanovic
Mad Scheme Limited










More information about the mapserver-users mailing list