JMapPane-getWorldToScreenTransform().getScaleX()

6 messages Options
Embed this post
Permalink
iceDice

JMapPane-getWorldToScreenTransform().getScaleX()

Reply Threaded More More options
Print post
Permalink
Hello,

I am interested what is meaning of data returned by JMapPane.getWorldToScreenTransform.getScaleX()
method. I need to know in every moment linear distance of the coordinate system of the map
in meters per pixel. Is it information returned by getScaleX() somehow related to that
what i need to get and how can i get from it (if it is possible).

Best regards.
mbedward

Re: JMapPane-getWorldToScreenTransform().getScaleX()

Reply Threaded More More options
Print post
Permalink
> I need to know in every moment linear distance of the coordinate
> system of the map in meters per pixel.

mapPane.getScreenToWorldTransform().getScaleX() will give you the
distance units per pixel value

Michael

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
iceDice

Re: JMapPane-getWorldToScreenTransform().getScaleX()

Reply Threaded More More options
Print post
Permalink
Hello Michael,

Thank you for quick reply.
So for example if getScaleX() returns 100 what that means,
100 mm per pixel, 100 inches per pixel or 100 m per pixel?

Thanks.

mbedward wrote:
> I need to know in every moment linear distance of the coordinate
> system of the map in meters per pixel.

mapPane.getScreenToWorldTransform().getScaleX() will give you the
distance units per pixel value

Michael

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
mbedward

Re: JMapPane-getWorldToScreenTransform().getScaleX()

Reply Threaded More More options
Print post
Permalink
> So for example if getScaleX() returns 100 what that means,
> 100 mm per pixel, 100 inches per pixel or 100 m per pixel?

It could be any of those :-)  The distance unit used will be the one
defined in the coordinate reference system of your shapefile or other
feature source. For example, a UTM data set will be in metres while a
WGS84 data set is in degrees.

You can query the unit of measurement used by a feature type with:
Unit<?> unit = featureType.getCoordinateReferenceSystem().getCoordinateSystem().getAxis(0),getUnit();
String unitName = unit.toString();

Hope that helps,

Michael

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
iceDice

Re: JMapPane-getWorldToScreenTransform().getScaleX()

Reply Threaded More More options
Print post
Permalink
Hi Michael,

I created DefaultMapContext with provided Geographic WGS84 CRS because
i don't have information about coordinate system in my feature source.
Is that mean that distance unit will be in degrees?

Maybe i am misunderstanding something but for example on some map scale
getScaleX() returns 6186.620896800171 and getScaleY() returns -6186.620896800171.
How could those values correspond to (Lat,Lon) degrees?

Best regards.

mbedward wrote:
> So for example if getScaleX() returns 100 what that means,
> 100 mm per pixel, 100 inches per pixel or 100 m per pixel?

It could be any of those :-)  The distance unit used will be the one
defined in the coordinate reference system of your shapefile or other
feature source. For example, a UTM data set will be in metres while a
WGS84 data set is in degrees.

You can query the unit of measurement used by a feature type with:
Unit<?> unit = featureType.getCoordinateReferenceSystem().getCoordinateSystem().getAxis(0),getUnit();
String unitName = unit.toString();

Hope that helps,

Michael

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
mbedward

Re: JMapPane-getWorldToScreenTransform().getScaleX()

Reply Threaded More More options
Print post
Permalink
Hi Nenad,

I'd need to have a look at your code. Normally (and I hope someone
will correct me if I'm wrong here) when you set a CRS for your map
context that determines the units that will be used for the bounds.

Shortly we will have a new example page on the web site that talks about this:

http://geotools.org/examples/crslab.html

(if it's not there when you look, check back again soon)

As of the last few days in the 2.6-SNAPSHOT, if you don't set a CRS
for your map context it will try to get one from the first layer that
you add that does have a CRS.

Of course, if you have a shapefile without a CRS (no .prj file) then
you can usually guess what the distance units are by visual
inspection. If they look like meters, and that is what you want, then
you shouldn't set WGS 84 as the projection for your context because
you will force it back to degrees.

I'm not sure that I've explained that very well !  Hope it makes sense.

Michael

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users