[OpenMap Users] Scaling the map to fit

From: Erno Kuusela <kuuserno_at_paju.oulu.fi>
Date: Mon, 07 Jan 2013 15:33:32 +0200

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"]
Received on Mon Jan 07 2013 - 08:36:04 EST

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