Mobile Map API

MGMaps Lib SDK is professional toolkit to develop mobile mapping applications.
Platforms: iPhone, Android, RIM BlackBerry, Java ME (J2ME)
Download maps API SDK »

Uudised

Viimane: Thu, 29 Jul 2010 19:38:21
Teema: New maps SDK release 1.1.0
Veel uudiseid »

Nutiteq Twitteris

11 weeks 1 day ago Nutiteq is proud sponsor of StateOfTheMap 2010 #sotm10

using mercator format : srid =900913

7 replies [Last post]
micka
User offline. Last seen 31 weeks 13 hours ago. Offline
Joined: 01/14/2010

Hi,

i've some point in mercator format, is it possible to use it ?
i would like to draw line, polygon, center the map with this mercator data.

is it possible ?

thanks,

jaak
User offline. Last seen 15 hours 33 min ago. Offline
Joined: 06/19/2008

Library has actually conversions for several coordinate systems, including Spherical Mercator what you mean here. However, these are converting coordinates to/from map image pixels (which are depending on map zoom), if you have coordinates in meters then it should be possible to convert them if you know size of pixel.

However, my suggestion would be to use geographical (WGS84, EPSG:4326) coordinates, like API uses directly (regardless of map's projection, this could be anything else). With other coordinate systems there are extra calculations needed which makes phone app slower. If you have data in another system then you should be able to convert them before getting data to the phone? Also: I have never seen Spherical Mercator coordinates in direct use, like projected coordinates in meters.

By the way, "Google's/Web Spherical Mercator" code is officially now EPSG:3785, so library uses this number, essentially it is same as 900913. Proper Mercator what geographers use something else, it is not spherical but uses some ellipsoid. Mercator with WGS84 Ellipsoid (EPSG:3395) is also supported in Lib SDK, and you can add also your custom projections to the library.

/JaakL

micka
User offline. Last seen 31 weeks 13 hours ago. Offline
Joined: 01/14/2010

thanks you very much,

i've an another problem which is :

Let the point be C (Cx,Cy) and the line be AB (Ax,Ay) to (Bx,By).
Let P be the point of perpendicular projection of C on AB

it seems that my point P is not good, [AB] and [PC] are not perpendicular, do you have an idea why ? do you have a solution ?

http://www.codeguru.com/forum/printthread.php?t=194400

public Point distanceToSegment(Point C, Point A, Point B){

double distAB_X=B.x-A.x;
double distAB_Y=B.y-A.y;

double L= Math.sqrt( (float)(distAB_X*distAB_X + distAB_Y*distAB_Y) );

double r = ( (A.y-C.y)*(A.y-B.y)-(A.x-C.x)*distAB_X )/(L*L);

if(r<0 || r>1)return null;
System.out.println("distoseg "+r);

Point5D p=new Point5D();
p.x = A.x + r*distAB_X;
p.y = A.y + r*distAB_Y;
return p;
}

jaak
User offline. Last seen 15 hours 33 min ago. Offline
Joined: 06/19/2008

You want to calculate distance from point? I do not have ready algorithm for, you but I'm sure you can find one which is using geographic coordinates as input. Using (Google) Mercator perhaps does not help you much, as it has huge distortion in higher latitudes (e.g. one Mercator meter is about 1.5 actual meters in Central Europe).

/JaakL

micka
User offline. Last seen 31 weeks 13 hours ago. Offline
Joined: 01/14/2010

about the distortion, how do you say that you are at Z altitude ?

new WgsPoint(longi,latt, altitude ? )

micka
User offline. Last seen 31 weeks 13 hours ago. Offline
Joined: 01/14/2010

sorry you speak about lattitude ......

and what about meters wgs84 ? what is the distortion about that in center europe ?

jaak
User offline. Last seen 15 hours 33 min ago. Offline
Joined: 06/19/2008

WGS84 usually refers to geographic coordinate system (the one used by GPS), it has degrees and no meters. If you need distance, then it can be calculated using Havershine formula or some other which uses geographic coordinates. See e.g. http://en.wikipedia.org/wiki/Haversine_formula and references there to get started.

Maps SDK has its implementation on com.nutiteq.components.WgsPoint.distanceInMeters() method.

/JaakL

jaak
User offline. Last seen 15 hours 33 min ago. Offline
Joined: 06/19/2008

About converting coordinates between projections see also http://www.nutiteq.com/epsg90013-epsg4326#comment-590 Similar approach can be used also for other possible conversions.

/JaakL