本文整理汇总了Java中org.openstreetmap.josm.data.coor.LatLon类的典型用法代码示例。如果您正苦于以下问题:Java LatLon类的具体用法?Java LatLon怎么用?Java LatLon使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LatLon类属于org.openstreetmap.josm.data.coor包,在下文中一共展示了LatLon类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: finish
import org.openstreetmap.josm.data.coor.LatLon; //导入依赖的package包/类
@Override
protected void finish() {
if (isFailed() || isCanceled())
return;
if (dataSet == null)
return; // user canceled download or error occurred
if (dataSet.allPrimitives().isEmpty()) {
rememberErrorMessage(tr("No data found in this area."));
// need to synthesize a download bounds lest the visual indication of downloaded
// area doesn't work
dataSet.dataSources.add(new DataSource(new Bounds(new LatLon(0, 0)), "i-locate server"));
}
saveUploadInfo();
downloadedData = dataSet;
Main.debug("[DownloadIlocateTask.DownloadTask.finish] Load data, type: "+type.toString());
loadData(newLayerName, null);
}
示例2: createSeparateBusStopNode
import org.openstreetmap.josm.data.coor.LatLon; //导入依赖的package包/类
/**
* Create separate bus stop node or assign bus stop tag to platform node
* @param commands Original command list
* @param stopArea Stop area object
* @param firstPlatform First platform in stop area relation
* @param tag Tag name
* @param tagValue Tag value
* @return Resulting command list
*/
protected List<Command> createSeparateBusStopNode(List<Command> commands, StopArea stopArea, OsmPrimitive firstPlatform, String tag, String tagValue)
{
if(commands == null)
commands = new ArrayList<Command>();
LatLon centerOfPlatform = getCenterOfWay(firstPlatform);
if(firstPlatform instanceof Way)
{
if(centerOfPlatform != null)
{
Node newNode =new Node();
newNode.setCoor(centerOfPlatform);
Main.main.undoRedo.add(new AddCommand(newNode));
Main.main.undoRedo.add(new ChangePropertyCommand(newNode, tag, tagValue));
commands = assignTag(commands, newNode, tag, tagValue);
stopArea.otherMembers.add(newNode);
}
}
else
{
commands = assignTag(commands, firstPlatform, tag, tagValue);
}
return commands;
}
示例3: getCenterOfWay
import org.openstreetmap.josm.data.coor.LatLon; //导入依赖的package包/类
/**
* Calculation of center of platform, if platform is way
* @param platform Platform primitive
* @return Coordinates of center of platform
*/
public static LatLon getCenterOfWay(OsmPrimitive platform)
{
if(platform instanceof Way)
{
//p = mapView.getPoint((Node) stopArea.selectedObject);
Double sumLat = 0.0;
Double sumLon = 0.0;
Integer countNode = 0;
for(Node node : ((Way) platform).getNodes())
{
LatLon coord = node.getCoor();
sumLat += coord.getX();
sumLon += coord.getY();
countNode++;
}
return new LatLon(sumLon / countNode, sumLat / countNode);
}
return null;
}
示例4: deserialize
import org.openstreetmap.josm.data.coor.LatLon; //导入依赖的package包/类
@Override
public CarPosition deserialize(final JsonElement jsonElement, final Type type,
final JsonDeserializationContext context) throws JsonParseException {
final JsonObject obj = (JsonObject) jsonElement;
final int heading = obj.get(HEADING).getAsInt();
final int accuracy = obj.get(ACCURACY).getAsInt();
final JsonElement carType = obj.get(TYPE);
String carPosType;
if (carType != null) {
carPosType = carType.getAsString();
} else {
carPosType = "";
}
final double lat = obj.get(LATITUDE).getAsDouble();
final double lon = obj.get(LONGITUDE).getAsDouble();
return new CarPosition(new LatLon(lat, lon), heading, accuracy, carPosType);
}
示例5: nearbyTile
import org.openstreetmap.josm.data.coor.LatLon; //导入依赖的package包/类
/**
* Returns the tile corresponding to the given point.
*
* @param tiles a {@code Tile} a list of available tiles
* @param point a {@code Point} represents the location where the user clicked on the map
* @return a {@code Tile} object
*/
public static Tile nearbyTile(final List<Tile> tiles, final Point point) {
Tile result = null;
final LatLon latLon = pointToLatLon(point);
final int tileX = getTileX(latLon.getX());
final int tileY = getTileY(latLon.getY());
if (tiles != null) {
for (final Tile tile : tiles) {
if (tile.equals(new Tile(tileX, tileY))) {
result = tile;
break;
}
}
}
return result;
}
示例6: actionPerformed
import org.openstreetmap.josm.data.coor.LatLon; //导入依赖的package包/类
@Override
public void actionPerformed(final ActionEvent event) {
final LatLon location = selectedItemCoordinate != null ? selectedItemCoordinate
: Main.map.mapView.getRealBounds().getCenter();
final int zoom = org.openstreetmap.josm.plugins.improveosm.util.Util.zoom(Main.map.mapView.getRealBounds());
switch (PreferenceManager.getInstance().loadLocationPrefOption()) {
case OPEN_STREET_VIEW:
openUrl(Config.getInstance().getLocationPrefOpenStreetView(),
location.latToString(CoordinateFormat.getDefaultFormat()),
location.lonToString(CoordinateFormat.getDefaultFormat()), String.valueOf(zoom));
break;
case CUSTOM_SITE:
openUrl(generateCustomURL(PreferenceManager.getInstance().loadLocationPrefValue()),
location.latToString(CoordinateFormat.getDefaultFormat()),
location.lonToString(CoordinateFormat.getDefaultFormat()), String.valueOf(zoom));
break;
case COPY_LOCATION:
ClipboardUtils.copyString(Formatter.formatLatLon(location));
}
}
示例7: arrowGeometry
import org.openstreetmap.josm.data.coor.LatLon; //导入依赖的package包/类
static Pair<Pair<Point, Point>, Pair<Point, Point>> arrowGeometry(final MapView mapView, final List<LatLon> points,
final boolean isFromSegment, final double length) {
LatLon arrowPoint;
double bearing;
if (isFromSegment) {
arrowPoint = points.size() > 2 ? points.get(points.size() / 2) : new LatLon(
(points.get(1).lat() + points.get(0).lat()) / 2, (points.get(1).lon() + points.get(0).lon()) / 2);
bearing = Math.toDegrees(points.get(points.size() - 1).bearing(arrowPoint));
} else {
arrowPoint = points.get(points.size() - 1);
bearing = Math.toDegrees(points.get(points.size() - 1).bearing(points.get(points.size() - 2)));
}
final Pair<Coordinate, Coordinate> arrowEndCoordinates =
GeometryUtil.arrowEndPoints(new Coordinate(arrowPoint.lat(), arrowPoint.lon()), bearing, length);
final Pair<Point, Point> arrowLine1 = new Pair<>(mapView.getPoint(arrowPoint), mapView.getPoint(
new LatLon(arrowEndCoordinates.getFirst().getLat(), arrowEndCoordinates.getFirst().getLon())));
final Pair<Point, Point> arrowLine2 = new Pair<>(mapView.getPoint(arrowPoint), mapView.getPoint(
new LatLon(arrowEndCoordinates.getSecond().getLat(), arrowEndCoordinates.getSecond().getLon())));
return new Pair<>(arrowLine1, arrowLine2);
}
示例8: drawItem
import org.openstreetmap.josm.data.coor.LatLon; //导入依赖的package包/类
@Override
void drawItem(final Graphics2D graphics, final MapView mapView, final Tile tile, final boolean selected) {
final Color borderColor = tile.getStatus() == Status.OPEN ? TILE_OPEN_COLOR
: (tile.getStatus() == Status.SOLVED ? TILE_SOLVED_COLOR : TILE_INVALID_COLOR);
final Color tileColor = tileColor(tile);
final Composite composite = selected ? TILE_SEL_COMPOSITE : TILE_COMPOSITE;
final BoundingBox bbox = Util.tileToBoundingBox(tile.getX(), tile.getY());
final Point northEast = mapView.getPoint(new LatLon(bbox.getNorth(), bbox.getEast()));
final Point northWest = mapView.getPoint(new LatLon(bbox.getSouth(), bbox.getWest()));
PaintManager.drawRectangle(graphics, northEast, northWest, NORMAL_COMPOSITE, composite, TILE_LINE_STROKE,
borderColor, tileColor);
final int radius = selected ? SEL_POINT_POS_RADIUS : POINT_POS_RADIUS;
// draw points belonging to the tile
if (tile.getPoints() != null && tile.getPoints().size() > 1) {
for (final LatLon latLon : tile.getPoints()) {
PaintManager.drawCircle(graphics, mapView.getPoint(latLon), POINT_COLOR, radius);
}
}
}
示例9: createNote
import org.openstreetmap.josm.data.coor.LatLon; //导入依赖的package包/类
public Note createNote(LatLon latlon, String text) throws OsmTransferException {
ProgressMonitor monitor = NullProgressMonitor.INSTANCE;
String encodedText;
try {
encodedText = URLEncoder.encode(text, "UTF-8");
}
catch(UnsupportedEncodingException e) {
e.printStackTrace();
return null;
}
String url = new StringBuilder()
.append("notes?lat=")
.append(latlon.lat())
.append("&lon=")
.append(latlon.lon())
.append("&text=")
.append(encodedText).toString();
String response = sendRequest("POST", url, null, monitor, true, false);
List<Note> newNote = parseNotes(response);
if(newNote.size() != 0) {
return newNote.get(0);
}
return null;
}
示例10: getNode
import org.openstreetmap.josm.data.coor.LatLon; //导入依赖的package包/类
public Node getNode(double x, double y) throws TransformException {
Coordinate c = new Coordinate(x, y);
if (nodes.containsKey(c)) {
return nodes.get(c);
} else {
src.x = -y;
src.y = -x;
Projection.convert_s_jtsk_to_etrs89(src, dst);
Node n = new Node();
n.setCoor(new LatLon(dst.y, dst.x));
nodes.put(c, n);
dataset.addPrimitive(n);
return n;
}
}
示例11: createNode
import org.openstreetmap.josm.data.coor.LatLon; //导入依赖的package包/类
private Node createNode(final LngLatAlt point) {
final double[] pt = new double[] {point.getLongitude(), point.getLatitude()};
final LatLon latlon = new LatLon(pt[1], pt[0]);
final Node node = new Node(latlon);
dataSet.addPrimitive(node);
return node;
}
示例12: mergeBounds
import org.openstreetmap.josm.data.coor.LatLon; //导入依赖的package包/类
private Bounds mergeBounds(final Bounds bounds, final LatLon coords) {
if (bounds == null) {
return new Bounds(coords);
} else {
bounds.extend(coords);
return bounds;
}
}
示例13: getNearestNode
import org.openstreetmap.josm.data.coor.LatLon; //导入依赖的package包/类
/**
* Search of nearest points on ways
* @param platformCoord Platform coordinates
* @param stopArea Stop area object
* @return Dictionary of founded points and distances from platform
*/
public AbstractMap.SimpleEntry<Double, Node> getNearestNode(LatLon platformCoord, StopArea stopArea)
{
Point p = Main.map.mapView.getPoint(platformCoord);
Map<Double, List<Node>> dist_nodes = getNearestNodesImpl(p);
Double[] distances = dist_nodes.keySet().toArray(new Double[0]);
distances = sort(distances);
Integer distanceIndex = -1;
Node nearestNode = null;
while(++distanceIndex < distances.length && nearestNode == null)
{
List<Node> nodes = dist_nodes.get(distances[distanceIndex]);
for(Node node : nodes)
{
for(Way way : getCurrentDataSet().getWays())
{
if(way.getNodes().contains(node) && testWay(way, stopArea))
{
nearestNode = node;
return new AbstractMap.SimpleEntry<Double, Node> (distances[distanceIndex], nearestNode);
}
}
if(nearestNode != null)
break;
}
}
return null;
}
示例14: getNearestWaySegment
import org.openstreetmap.josm.data.coor.LatLon; //导入依赖的package包/类
/**
* Selection of nearest way for stop position
* @param platformCoord Platform coordinates
* @param stopArea Stop area
* @return Nearest way segment
*/
protected NearestWaySegment getNearestWaySegment(LatLon platformCoord, StopArea stopArea)
{
Point p = Main.map.mapView.getPoint(platformCoord);
Map<Double, List<WaySegment>> dist_waySegments = getNearestWaySegmentsImpl(p);
for(Map.Entry<Double, List<WaySegment>> entry : dist_waySegments.entrySet())
{
for(WaySegment waySegment : entry.getValue())
{
if(testWay(waySegment.way, stopArea))
{
Node n = waySegment.getFirstNode();
Node lastN = waySegment.getSecondNode();
EastNorth newPosition = Geometry.closestPointToSegment(n.getEastNorth(),
lastN.getEastNorth(), Projections.project(platformCoord));
LatLon newNodePosition = Projections.inverseProject(newPosition);
Point2D lastN2D = Main.map.mapView.getPoint2D(lastN);
Point2D n2D = Main.map.mapView.getPoint2D(n);
Point2D newNodePosition2D = Main.map.mapView.getPoint2D(newNodePosition);
Double distCurrenNodes =lastN2D.distance(n2D);
if((newNodePosition2D.distance(lastN2D) < distCurrenNodes) && (newNodePosition2D.distance(n2D) < distCurrenNodes))
{
return new NearestWaySegment(entry.getKey(), waySegment, new Node(newNodePosition));
}
}
}
}
return null;
}
示例15: deserialize
import org.openstreetmap.josm.data.coor.LatLon; //导入依赖的package包/类
@Override
public LatLon deserialize(final JsonElement jsonElement, final Type type, final JsonDeserializationContext context)
throws JsonParseException {
final JsonObject obj = (JsonObject) jsonElement;
final double lat = obj.get(LATITUDE).getAsDouble();
final double lon = obj.get(LONGITUDE).getAsDouble();
return new LatLon(lat, lon);
}