/osmdroid-third-party/src/main/java/org/osmdroid/google/wrapper/v2/Projection.java
Java | 55 lines | 44 code | 11 blank | 0 comment | 2 complexity | 414aa62a8be6a7c147aa093b895593d7 MD5 | raw file
1package org.osmdroid.google.wrapper.v2; 2 3import com.google.android.gms.maps.model.LatLng; 4import com.google.android.gms.maps.model.LatLngBounds; 5import org.osmdroid.api.IGeoPoint; 6import org.osmdroid.api.IProjection; 7 8import android.graphics.Point; 9 10public class Projection implements IProjection { 11 12 private final com.google.android.gms.maps.Projection mProjection; 13 14 private final Point mPoint = new Point(); 15 16 public Projection(final com.google.android.gms.maps.Projection aProjection) { 17 mProjection = aProjection; 18 } 19 20 @Override 21 public Point toPixels(final IGeoPoint in, final Point out) { 22 final LatLng latLng = new LatLng(in.getLatitude(), in.getLongitude()); 23 final Point point = mProjection.toScreenLocation(latLng); 24 if (out != null) { 25 out.x = point.x; 26 out.y = point.y; 27 } 28 return point; 29 } 30 31 @Override 32 public IGeoPoint fromPixels(final int x, final int y) { 33 mPoint.x = x; 34 mPoint.y = y; 35 final LatLng latLng = mProjection.fromScreenLocation(mPoint); 36 return new GeoPoint(latLng); 37 } 38 39 @Override 40 public float metersToEquatorPixels(final float meters) { 41 return 0; // TODO implement this 42 } 43 44 @Override 45 public IGeoPoint getNorthEast() { 46 final LatLngBounds bounds = mProjection.getVisibleRegion().latLngBounds; 47 return new GeoPoint(bounds.northeast); 48 } 49 50 @Override 51 public IGeoPoint getSouthWest() { 52 final LatLngBounds bounds = mProjection.getVisibleRegion().latLngBounds; 53 return new GeoPoint(bounds.southwest); 54 } 55}