[Mapserver-users] WMS BBOX vs. Actual Bounds

Steve Lime steve.lime at dnr.state.mn.us
Wed Jan 7 12:42:32 PST 2004


This is a MIME message. If you are reading this text, you may want to 
consider changing to a mail reader or gateway that understands how to 
properly handle MIME multipart messages.

--=__PartECB22228.1__=
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

There's no way with pure WMS (that I know of) to get the computed bounds
back other than by precomputing them to perfectly fit your requested
image size. I've done that with a java digitizing client that took WMS
images from MapServer and overlayed information from a seperate SDE/Java
application. Worked fine. I've attached the simple map geometry class I
used in that case, look at the fit method.

Regarding bounds computation. MapServer gaurantees that the requested
extent will fit in the image, so one of the dimensions will remain fixed
while the other is expanded as necessary. The decision as to which to
expand is based on how the extent is oriented (think portrait vs
landscape) relative to the "shape" of the image. The idea is to minimize
stuff outside the extent.

Steve

Stephen Lime
Data & Applications Manager

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

>>> John Gorkos <jgorkos at lenexa.sema.slb.com> 1/7/2004 12:20:20 PM >>>
Howdy-
  My programming team is up against a hard deadline, and we're
stymied.
Basic project is this:  use a WMS mapserver to feed a java applet a
base map, 
and then connect (via TCP) to a real-time management system that feeds
us 
status of devices across the planet, coded by lat/long and a status
code.  
These then get overlayed on top of the base map on a "glass pane" that
can be 
changed without redrawing the base.  The result is little winkin',
blinkin' 
lights on top of a map that show (in our case) whether or not
electricity is 
on in various places across the US.
  The problem is that when we send a BBOX request to the mapserver from
the 
java applet, we don't get back a map with the exact coordinates we
asked for.  
That's OK, I realize that mapserver gets as close as it can given the
image 
size, but I've GOT to know what the real boundaries are so I can
overlay my 
status dots on top.  How do I get this information back from the
mapserver?
  On a related thread, how does the mapserver decide what the real
boundaries 
are, when given when the bounds requested don't match the aspect ratio
of the 
returned image?
-- 
John Gorkos
SchlumbergerSema/Atos-Origin
_______________________________________________
Mapserver-users mailing list
Mapserver-users at lists.gis.umn.edu 
http://lists.gis.umn.edu/mailman/listinfo/mapserver-users

--=__PartECB22228.1__=
Content-Type: application/octet-stream; name="MapGeometry.java"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="MapGeometry.java"

aW1wb3J0IGphdmEuYXd0LkRpbWVuc2lvbjsKCnB1YmxpYyBjbGFzcyBNYXBHZW9tZXRyeSB7CiAg
ZG91YmxlIG1pbngsIG1pbnksIG1heHgsIG1heHk7CiAgZG91YmxlIGNlbGxzaXplOwogIERpbWVu
c2lvbiBzaXplOwoKICBwdWJsaWMgTWFwR2VvbWV0cnkoZG91YmxlIHgxLCBkb3VibGUgeTEsIGRv
dWJsZSB4MiwgZG91YmxlIHkyLCBEaW1lbnNpb24gc2l6ZSkgewogICAgdGhpcy5zaXplID0gc2l6
ZTsKCiAgICB0aGlzLm1pbnggPSBNYXRoLm1pbih4MSwgeDIpOwogICAgdGhpcy5taW55ID0gTWF0
aC5taW4oeTEsIHkyKTsKICAgIHRoaXMubWF4eCA9IE1hdGgubWF4KHgxLCB4Mik7CiAgICB0aGlz
Lm1heHkgPSBNYXRoLm1heCh5MSwgeTIpOwoKICAgIHRoaXMuZml0KCk7CiAgfQoKICBwdWJsaWMg
dm9pZCBwb2ludFpvb20oZG91YmxlIHgsIGRvdWJsZSB5LCBkb3VibGUgem9vbSkgewogICAgZG91
YmxlIGR4LCBkeTsKICAgIGRvdWJsZSBteCwgbXk7CgogICAgZHggPSB0aGlzLm1heHggLSB0aGlz
Lm1pbng7CiAgICBkeSA9IHRoaXMubWF4eSAtIHRoaXMubWlueTsKICAgIG14ID0gdGhpcy5taW54
ICsgdGhpcy5jZWxsc2l6ZSp4OyAvLyBjb252ZXJ0ICpjbGljayogdG8gbWFwIGNvb3JkaW5hdGVz
CiAgICBteSA9IHRoaXMubWF4eSAtIHRoaXMuY2VsbHNpemUqeTsKCiAgICB0aGlzLm1pbnggPSBt
eCAtIC41KihkeC96b29tKTsKICAgIHRoaXMubWlueSA9IG15IC0gLjUqKGR5L3pvb20pOwogICAg
dGhpcy5tYXh4ID0gbXggKyAuNSooZHgvem9vbSk7CiAgICB0aGlzLm1heHkgPSBteSArIC41Kihk
eS96b29tKTsgCgogICAgdGhpcy5maXQoKTsKICB9CgogIHB1YmxpYyB2b2lkIHBvaW50Wm9vbShk
b3VibGUgeCwgZG91YmxlIHksIGRvdWJsZSB6b29tc2l6ZSwgaW50IHpvb21kaXIpIHsKICAgIGRv
dWJsZSBkeCwgZHk7CiAgICBkb3VibGUgbXgsIG15OwoKICAgIGRvdWJsZSB6b29tOwoKICAgIGlm
KHpvb21kaXIgPT0gMSAmJiB6b29tc2l6ZSAhPSAwKQogICAgICB6b29tID0gem9vbXNpemU7CiAg
ICBlbHNlIGlmKHpvb21kaXIgPT0gLTEgJiYgem9vbXNpemUgIT0gMCkKICAgICAgem9vbSA9IDEv
em9vbXNpemU7CiAgICBlbHNlCiAgICAgIHpvb20gPSAxLjA7CgogICAgZHggPSB0aGlzLm1heHgg
LSB0aGlzLm1pbng7CiAgICBkeSA9IHRoaXMubWF4eSAtIHRoaXMubWlueTsKICAgIG14ID0gdGhp
cy5taW54ICsgdGhpcy5jZWxsc2l6ZSp4OyAvLyBjb252ZXJ0ICpjbGljayogdG8gbWFwIGNvb3Jk
aW5hdGVzCiAgICBteSA9IHRoaXMubWF4eSAtIHRoaXMuY2VsbHNpemUqeTsKCiAgICB0aGlzLm1p
bnggPSBteCAtIC41KihkeC96b29tKTsKICAgIHRoaXMubWlueSA9IG15IC0gLjUqKGR5L3pvb20p
OwogICAgdGhpcy5tYXh4ID0gbXggKyAuNSooZHgvem9vbSk7CiAgICB0aGlzLm1heHkgPSBteSAr
IC41KihkeS96b29tKTsgCgogICAgdGhpcy5maXQoKTsKICB9CgogIHB1YmxpYyB2b2lkIGJveFpv
b20oZG91YmxlIHgxLCBkb3VibGUgeTEsIGRvdWJsZSB4MiwgZG91YmxlIHkyKSB7CiAgICBkb3Vi
bGUgbWlueCwgbWlueSwgbWF4eCwgbWF4eTsKCiAgICBtaW54ID0gdGhpc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s
bWlueCxjeCkgKE1TX05JTlQoKHggLSBtaW54KS9jeCkpCiAgLy8gI2RlZmluZSBNU19NQVAySU1B
R0VfWSh5LG1heHksY3kpIChNU19OSU5UKChtYXh5IC0geSkvY3kpKQoKICBwdWJsaWMgZG91Ymxl
IG1hcFRvUGl4ZWxYKGRvdWJsZSB4KSB7CiAgICByZXR1cm4oKHggLSB0aGlzLm1pbngpL3RoaXMu
Y2VsbHNpemUpOwogIH0KCiAgcHVibGljIGRvdWJsZSBtYXBUb1BpeGVsWShkb3VibGUgeSkgewog
ICAgcmV0dXJuKCh0aGlzLm1heHkgLSB5KS90aGlzLmNlbGxzaXplKTsKICB9CgogIHB1YmxpYyBT
dHJpbmcgYXNTdHJpbmcoKSB7CiAgICByZXR1cm4odGhpcy5taW54ICsgIiwiICsgdGhpcy5taW55
ICsgIiwiICsgdGhpcy5tYXh4ICsgIiwiICsgdGhpcy5tYXh5KTsKICB9Cn0K

--=__PartECB22228.1__=--



More information about the MapServer-users mailing list