android - Calculate latitude longitude for added height -
i want draw line chart on android google map. have gps coordinates of path , want show speed of car on map height of line.
see image this,
for each gps (lat,lng) point want add height , calculate corresponding gps(lat,lng) point. want show in 3d view have change points when camera position changed first step calculate gps points added height.
for example
arraylist<latlng> basepoints = new arraylist<latlng>(); basepoints.add(new latlng(53.262688, -2.500792)); basepoints.add(new latlng(53.262758, -2.500897)); basepoints.add(new latlng(53.262789, -2.501087)); basepoints.add(new latlng(53.262798, -2.501229)); basepoints.add(new latlng(53.262785, -2.501414)); basepoints.add(new latlng(53.262760, -2.501594)); basepoints.add(new latlng(53.262707, -2.501811)); basepoints.add(new latlng(53.262655, -2.501943)); arraylist<latlng> toppoints = new arraylist<latlng>(); toppoints.add(new latlng(53.262939, -2.500779)); toppoints.add(new latlng(53.262975, -2.500916)); toppoints.add(new latlng(53.262914, -2.501098)); toppoints.add(new latlng(53.263055, -2.501248)); toppoints.add(new latlng(53.262925, -2.501439)); toppoints.add(new latlng(53.263045, -2.501581)); toppoints.add(new latlng(53.262907, -2.501844)); toppoints.add(new latlng(53.263002, -2.502015));
any idea how can it? thanks
from link provided have implemented you.
final arraylist<latlng> basepoints = new arraylist<latlng>(); basepoints.add(new latlng(53.262688, -2.500792)); basepoints.add(new latlng(53.262758, -2.500897)); basepoints.add(new latlng(53.262789, -2.501087)); basepoints.add(new latlng(53.262798, -2.501229)); basepoints.add(new latlng(53.262785, -2.501414)); basepoints.add(new latlng(53.262760, -2.501594)); basepoints.add(new latlng(53.262707, -2.501811)); basepoints.add(new latlng(53.262655, -2.501943)); final arraylist<double> speedpoints = new arraylist<double>(); speedpoints.add(7.955734692); speedpoints.add(8.761378798); speedpoints.add(11.07760474); speedpoints.add(13.69594751); speedpoints.add(15.50864695); speedpoints.add(16.01217576); speedpoints.add(15.60935179); speedpoints.add(15.71005663); latlngbounds.builder bounds = new latlngbounds.builder(); for(int i=0;i<basepoints.size();i++) { bounds.include(basepoints.get(i)); } map.movecamera(cameraupdatefactory.newlatlngbounds(bounds.build(), 300,300,0)); map.setoncamerachangelistener(new oncamerachangelistener() { @override public void oncamerachange(cameraposition arg0) { map.clear(); arraylist<latlng> toppoints = new arraylist<latlng>(); for(int i=0;i<basepoints.size();i++) { toppoints.add(movebydistance(basepoints.get(i), speedpoints.get(i)*3,map.getcameraposition().bearing)); } polylineoptions toppo = new polylineoptions(); toppo.addall(toppoints).width(5).color(color.blue).geodesic(true); map.addpolyline(toppo); for(int i=0;i<basepoints.size()-1;i++) { map.addpolygon(new polygonoptions().add(basepoints.get(i),toppoints.get(i),toppoints.get(i+1),basepoints.get(i+1),basepoints.get(i)).fillcolor(color.yellow).strokecolor(color.yellow)); } } }); /** * move latlng-point given distance , given angle (0-360, * 0=north). */ public static latlng movebydistance(latlng startgp, double distance,double angle) { /* * calculate part going north , part going east. */ double arc = math.toradians(angle); double tonorth = distance * math.cos(arc); double toeast = distance * math.sin(arc); double londiff = metertolongitude(toeast, startgp.latitude); double latdiff = metertolatitude(tonorth); return new latlng(startgp.latitude + latdiff, startgp.longitude + londiff); } private static double metertolongitude(double metertoeast, double latitude) { double latarc = math.toradians(latitude); double radius = math.cos(latarc) * earthradius; double rad = metertoeast / radius; double degrees = math.todegrees(rad); return degrees; } private static double metertolatitude(double metertonorth) { double rad = metertonorth / earthradius; double degrees = math.todegrees(rad); return degrees; }
i hope implement this.
Comments
Post a Comment