Re: [OpenMap Users] Scaling the map to fit

From: Erno Kuusela <kuuserno_at_paju.oulu.fi>
Date: Thu, 17 Jan 2013 13:56:41 +0200

Yes, the bottom and top portions are clipped and only middle section of
the map is showing. I can't remember the exact proportions of the map,
but its width:height ratio is around 1:2. The map window is resizable.
If the width and height of the window somewhat match the proportions of
the map, the scaling works. But for example, if the window is square,
map fits only horizontally.

Since my previous post I replaced the map data with one that has more
square proportions, but it still seems to clip top and bottom out.

-Erno

On 11.1.2013 6:19, Don Dietrick wrote:
> 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 17 2013 - 06:58:17 EST

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