当前位置: 首页>>代码示例>>Java>>正文


Java LatLon类代码示例

本文整理汇总了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);
}
 
开发者ID:STEMLab,项目名称:JOSM-IndoorEditor,代码行数:18,代码来源:DownloadIlocateTask.java

示例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;
}
 
开发者ID:bwr57,项目名称:CustomizePublicTransportStop,代码行数:34,代码来源:CustomizeStopAreaOperation.java

示例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;
  }
 
开发者ID:bwr57,项目名称:CustomizePublicTransportStop,代码行数:25,代码来源:StopAreaOperationBase.java

示例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);
}
 
开发者ID:Telenav,项目名称:scoutsigns,代码行数:18,代码来源:CarPositionDeserializer.java

示例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;
}
 
开发者ID:Telenav,项目名称:improve-osm-plugin,代码行数:23,代码来源:Util.java

示例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));
    }
}
 
开发者ID:Telenav,项目名称:improve-osm-plugin,代码行数:22,代码来源:ButtonPanel.java

示例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);
}
 
开发者ID:Telenav,项目名称:improve-osm-plugin,代码行数:23,代码来源:PaintUtil.java

示例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);
        }
    }
}
 
开发者ID:Telenav,项目名称:improve-osm-plugin,代码行数:21,代码来源:MissingGeometryHanlder.java

示例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;
}
 
开发者ID:iandees,项目名称:josm-notes,代码行数:26,代码来源:NotesCapableOsmApi.java

示例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;
	}
}
 
开发者ID:MilanNobonn,项目名称:freemapKaPor,代码行数:19,代码来源:NodeCollection.java

示例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;
}
 
开发者ID:JOSM,项目名称:geojson,代码行数:10,代码来源:DataSetBuilder.java

示例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;
    }
}
 
开发者ID:JOSM,项目名称:geojson,代码行数:9,代码来源:DataSetBuilder.java

示例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;
}
 
开发者ID:bwr57,项目名称:CustomizePublicTransportStop,代码行数:34,代码来源:CreateNewStopPointOperation.java

示例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;
}
 
开发者ID:bwr57,项目名称:CustomizePublicTransportStop,代码行数:37,代码来源:CreateNewStopPointOperation.java

示例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);
}
 
开发者ID:Telenav,项目名称:scoutsigns,代码行数:9,代码来源:LatLonDeserializer.java


注:本文中的org.openstreetmap.josm.data.coor.LatLon类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。