use of com.codename1.maps.Coord in project CodenameOne by codenameone.
the class Tile method pointPosition.
/**
* Returns the x, y point of the given coordinate relative to this tile
* @param point a coordinate to translate to x, y
* @return a Point object relative to this tile
*/
public Point pointPosition(Coord point) {
int x = position(dimension.getWidth(), point.getLongitude(), bbox.getSouthWest().getLongitude(), bbox.getNorthEast().getLongitude());
int y = position(dimension.getHeight(), point.getLatitude(), bbox.getSouthWest().getLatitude(), bbox.getNorthEast().getLatitude());
//
return new Point(x, dimension.getHeight() - y);
}
use of com.codename1.maps.Coord in project CodenameOne by codenameone.
the class LinesLayer method paint.
/**
* {@inheritDoc}
*/
public void paint(Graphics g, Tile screenTile) {
g.setColor(_lineColor);
g.setAntiAliased(true);
int segmentsNo = _lineSegments.size();
for (int i = 0; i < segmentsNo; i++) {
paintSegment(g, (Coord[]) _lineSegments.elementAt(i), screenTile);
}
}
use of com.codename1.maps.Coord in project CodenameOne by codenameone.
the class LinesLayer method boundingBox.
/**
* {@inheritDoc}
*/
public BoundingBox boundingBox() {
BoundingBox bbox = null;
for (int i = 0; i < _lineSegments.size(); i++) {
Coord[] coords = (Coord[]) _lineSegments.elementAt(i);
BoundingBox cBbox = BoundingBox.create(coords);
if (bbox == null) {
bbox = cBbox;
} else {
bbox = bbox.extend(cBbox);
}
}
return bbox;
}
use of com.codename1.maps.Coord in project CodenameOne by codenameone.
the class PointsLayer method removePoint.
/**
* Removes a point from the PointsLayer
*
* @param point to remove from the PointsLayer
*/
public void removePoint(PointLayer point) {
if (!point.isProjected()) {
Coord c = getProjection().fromWGS84(point);
point.setLatitude(c.getLatitude());
point.setLongitude(c.getLongitude());
point.setProjected(true);
}
points.removeElement(point);
}
use of com.codename1.maps.Coord in project CodenameOne by codenameone.
the class MapProvider method maxZoomFor.
/**
* Returns the maximum zoom of a specific Tile.
* @param tile tile to check the max zoom
* @return the max zoom of the tile
*/
public int maxZoomFor(Tile tile) {
int zoom;
int height = tile.dimension().getHeight();
int width = tile.dimension().getWidth();
double latitude = tile.getBoundingBox().latitudeDifference();
double longitude = tile.getBoundingBox().longitudeDifference();
for (zoom = maxZoomLevel(); zoom > 0; zoom--) {
Coord scale = scale(zoom);
if ((scale.getLatitude() * height) > latitude && (scale.getLongitude() * width) > longitude) {
break;
}
}
return zoom;
}
Aggregations