RE: [OpenMap Users] finding extents of map?

From: Ben Podoll <benjamin.podoll_at_und.edu>
Date: Sun, 8 Aug 2004 09:13:25 -0500

Ok I put my code later in my class file and it seems to report the size of
the mapBean correctly but I still don't understand why the "upper left" and
"lower right" are giving me seemingly wrong values? Since my resolution is
1600x1200 does OpenMap assume that the entire extents are that big or
something? And then when I do the forward methods it is giving me what you
see below: (so I am obviously still confused about this).

I just want to know what the extents are of the viewable area of the map and
then use the SpatialIndex class and its locateRecords() method (which I need
the associated x,y points that define the extents for parameters)

MapBean mb = basicMapPanel.getMapBean();
println("mapbean width: " + mb.getWidth());
println("mapbean height: " + mb.getHeight());
Projection proj = mb.getProjection();
LatLonPoint upperLeft = proj.getUpperLeft();
LatLonPoint lowerRight = proj.getLowerRight();
println("center: " + proj.getCenter().toString());
println("upper left: " + upperLeft.toString());
println("lower right: " + lowerRight.toString());
println("width: " + String.valueOf(proj.getWidth()));
println("height: " + String.valueOf(proj.getHeight()));
println("scale: " + String.valueOf(proj.getScale()));
println("upper left (x,y): " + proj.forward(upperLeft));
println("lower right (x,y): " + proj.forward(lowerRight));

And the output is:

mapbean width: 766
mapbean height: 543
center: LatLonPoint[lat=43.724747,lon=-94.012375]
upper left: LatLonPoint[lat=56.325226,lon=-120.36881]
lower right: LatLonPoint[lat=27.789461,lon=-67.65593]
width: 1600
height: 1200
scale: 1.2E7
upper left (x,y): java.awt.Point[x=0,y=0]
lower right (x,y): java.awt.Point[x=1600,y=1200]

I have also attached a screen shot of what is displayed when it pops up. So
as you can see the extents above are not associated with the viewable area.

> -----Original Message-----
> From: Rob Ratcliff [mailto:rrr6399_at_futuretek.com]
> Sent: Sunday, August 08, 2004 4:31 AM
> To: Ben Podoll
> Subject: RE: [OpenMap Users] finding extents of map?
>
> Ben,
>
> Since the mapbean is a panel, couldn't you get the width and height
> directly from that? Then assume that upper left is (0,0) and
> lower right is (w,h)?
>
> It looks like there is some problem with the .forward() method. Are you
> calling this method after the map has been rendered to the
> screen? (i.e. not during the construction of the map or before the
> basicMapPanel has been added to a parent that is visible?) (If
> your width and height is 0 you'll know that it is at the wrong time and
> you'll have to put your calculations in an invokeLater()).
>
> Rob
>
>
> inal Message-----
> > From: owner-openmap-users_at_bbn.com [mailto:owner-openmap-
> users_at_bbn.com]On
> > Behalf Of Ben Podoll
> > Sent: Saturday, August 07, 2004 10:25 PM
> > To: openmap-users_at_bbn.com
> > Subject: [OpenMap Users] finding extents of map?
> >
> >
> > I am having trouble finding the extents of my display (am I doing it
> > wrong?):
> >
> > Projection proj = basicMapPanel.getMapBean().getProjection();
> > LatLonPoint upperLeft = proj.getUpperLeft();
> > LatLonPoint lowerRight = proj.getLowerRight();
> > println("center: " + proj.getCenter().toString());
> > println("upper left: " + upperLeft.toString());
> > println("lower right: " + lowerRight.toString());
> > println("width: " + String.valueOf(proj.getWidth()));
> > println("height: " + String.valueOf(proj.getHeight()));
> > println("scale: " + String.valueOf(proj.getScale()));
> > println("upper left (x,y): " + proj.forward(upperLeft));
> > println("lower right (x,y): " + proj.forward(lowerRight));
> >
> > Here is my output:
> >
> > center: LatLonPoint[lat=43.724747,lon=-94.012375]
> > upper left: LatLonPoint[lat=56.325226,lon=-120.36881]
> > lower right: LatLonPoint[lat=27.789461,lon=-67.65593]
> > width: 1600
> > height: 1200
> > scale: 1.2E7
> > upper left (x,y): java.awt.Point[x=0,y=0]
> > lower right (x,y): java.awt.Point[x=1600,y=1200]
> >
> > My display GUI is very small and it states that the lower right
> corner is
> > 1600,1200? But that is the resolution of my entire screen, and the
> GUI is
> > way smaller.
> >
> > The whole reason for this is that I want to determine what shapes (in
> a
> > shapefile) are valid for my current view. Per a previous response to
> another
> > email I sent to the openmap userlist I am using a SpatialIndex like
> so:
> >
> > SpatialIndex si = new
> > SpatialIndex(ssx.toExternalForm(),shp.toExternalForm());
> > si.dumpIndex(true);
> > ESRIRecord[] shapes = si.locateRecords(?, ?, ?, ?);
> > System.out.println(shapes.length);
> >
> > But I don't know what to put for the locateRecords() parameter... Can
> > someone give me a pointer? I assume it is x,y values which I don't
> know how
> > to give.
> >
> >
> > --
> > [To unsubscribe to this list send an email to "majdart_at_bbn.com"
> > with the following text in the BODY of the message "unsubscribe
> openmap-users"]
> >
>





--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]

gisview.gif
(image/gif attachment: gisview.gif)

Received on Sun Aug 08 2004 - 10:14:27 EDT

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:05 EDT