Re: [OpenMap Users] Scaling the map to fit

From: Don Dietrick <dfdietrick_at_gmail.com>
Date: Thu, 10 Jan 2013 23:19:43 -0500

Hi Erno,

How do the proportions of the data compare to the window? It sounds like you are saying that the data fits horizontally in the map, but the top and bottom of the data are being clipped? I'm not sure what's going on.

It looks like you are doing things the right way. The NavMouseMode (and NavMouseMode2) are the best example of calling that getScale method, since they are zooming to the drawn window.

- Don


On Jan 7, 2013, at 8:33 AM, Erno Kuusela wrote:

> Hi
>
> I'm trying to scale my map to make it fit entirely inside the MapBean. I get the top left and bottom right corners from shape layer's getDataBounds() method, and the coordinates seem to make sense. However, the getScale() method in class ProjMath returns scale that fits the map only in the horizontal direction. My map is quite tall (its length is more than width), so most of the map gets clipped out.
>
> Here's the code I'm using:
>
> Projection proj = map.getProjection();
> DataBounds bounds = mainShapeLayer.getDataBounds();
> Point2D c1 = bounds.getMax();
> Point2D c2 = bounds.getMin();
> LatLonPoint topLeft = new LatLonPoint.Double( Math.max(c1.getY(), c2.getY()), Math.min(c1.getX(), c2.getX()) );
> LatLonPoint bottomRight = new LatLonPoint.Double( Math.min(c1.getY(), c2.getY()), Math.max(c1.getX(), c2.getX()) );
> float scale = com.bbn.openmap.proj.ProjMath.getScale( topLeft, bottomRight, proj );
> map.setScale( scale );
> map.setCenter( bounds.getCenter() );
>
> Am I doing something wrong here? I'm new to this stuff, so things seem to be quite confusing sometimes.
>
> --
> [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"]
Received on Thu Jan 10 2013 - 23:22:21 EST

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