- Timestamp:
- 2017-05-15T15:43:30+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/CopyCoordinatesAction.java
r11381 r12161 31 31 StringBuilder s = new StringBuilder(); 32 32 for (Node n : getSelectedNodes()) { 33 s.append(n. getCoor().lat());33 s.append(n.lat()); 34 34 s.append(", "); 35 s.append(n. getCoor().lon());35 s.append(n.lon()); 36 36 s.append('\n'); 37 37 } -
trunk/src/org/openstreetmap/josm/actions/SimplifyWayAction.java
r11488 r12161 245 245 Node n = wnew.get(i); 246 246 double xte = Math.abs(Ellipsoid.WGS84.a 247 * xtd(fromN.getCoor().lat() * Math.PI / 180, fromN.getCoor().lon() * Math.PI / 180, toN.getCoor().lat() * Math.PI 248 / 180, toN.getCoor().lon() * Math.PI / 180, n.getCoor().lat() * Math.PI / 180, n.getCoor().lon() * Math.PI 249 / 180)); 247 * xtd(fromN.lat() * Math.PI / 180, fromN.lon() * Math.PI / 180, toN.lat() * Math.PI / 180, 248 toN.lon() * Math.PI / 180, n.lat() * Math.PI / 180, n.lon() * Math.PI / 180)); 250 249 if (xte > xtemax) { 251 250 xtemax = xte; -
trunk/src/org/openstreetmap/josm/data/Bounds.java
r11747 r12161 10 10 import java.util.function.Consumer; 11 11 12 import org.openstreetmap.josm.data.coor.ILatLon; 12 13 import org.openstreetmap.josm.data.coor.LatLon; 13 14 import org.openstreetmap.josm.data.osm.BBox; … … 18 19 * This is a simple data class for "rectangular" areas of the world, given in 19 20 * lat/lon min/max values. The values are rounded to LatLon.OSM_SERVER_PRECISION 21 * 22 * @see BBox to represent invalid areas. 20 23 * 21 24 * @author imi … … 390 393 /** 391 394 * Determines if the given point {@code ll} is within these bounds. 395 * <p> 396 * Points with unknown coordinates are always outside the coordinates. 392 397 * @param ll The lat/lon to check 393 398 * @return {@code true} if {@code ll} is within these bounds, {@code false} otherwise 394 399 */ 395 400 public boolean contains(LatLon ll) { 401 // binary compatibility 402 return contains((ILatLon) ll); 403 } 404 405 /** 406 * Determines if the given point {@code ll} is within these bounds. 407 * <p> 408 * Points with unknown coordinates are always outside the coordinates. 409 * @param ll The lat/lon to check 410 * @return {@code true} if {@code ll} is within these bounds, {@code false} otherwise 411 * @since xxx 412 */ 413 public boolean contains(ILatLon ll) { 414 if (!ll.isLatLonKnown()) { 415 return false; 416 } 396 417 if (ll.lat() < minLat || ll.lat() > maxLat) 397 418 return false; -
trunk/src/org/openstreetmap/josm/data/coor/CachedLatLon.java
r10334 r12161 5 5 6 6 import org.openstreetmap.josm.Main; 7 import org.openstreetmap.josm.data.projection.Projecting; 7 8 import org.openstreetmap.josm.data.projection.Projection; 8 9 … … 20 21 21 22 private EastNorth eastNorth; 22 private transient Projection proj;23 private transient Object cacheKey; 23 24 24 25 /** … … 37 38 public CachedLatLon(LatLon coor) { 38 39 super(coor.lat(), coor.lon()); 39 proj= null;40 cacheKey = null; 40 41 } 41 42 … … 45 46 */ 46 47 public CachedLatLon(EastNorth eastNorth) { 47 super(Main.getProjection().eastNorth2latlon(eastNorth)); 48 proj = Main.getProjection(); 48 this(eastNorth, Main.getProjection()); 49 } 50 51 private CachedLatLon(EastNorth eastNorth, Projection projection) { 52 super(projection.eastNorth2latlon(eastNorth)); 53 cacheKey = projection.getCacheKey(); 49 54 this.eastNorth = eastNorth; 50 55 } … … 55 60 * @return the internally cached east/north coordinates. null, if the globally defined projection is null 56 61 */ 57 public final EastNorth getEastNorth() { 58 if (!Objects.equals(proj, Main.getProjection())) { 59 proj = Main.getProjection(); 60 eastNorth = proj.latlon2eastNorth(this); 62 @Override 63 public final EastNorth getEastNorth(Projecting projecting) { 64 if (!Objects.equals(cacheKey, projecting.getCacheKey())) { 65 cacheKey = projecting.getCacheKey(); 66 eastNorth = projecting.latlon2eastNorth(this); 61 67 } 62 68 return eastNorth; -
trunk/src/org/openstreetmap/josm/data/coor/LatLon.java
r12131 r12161 43 43 * @author Imi 44 44 */ 45 public class LatLon extends Coordinate {45 public class LatLon extends Coordinate implements ILatLon { 46 46 47 47 private static final long serialVersionUID = 1L; … … 251 251 } 252 252 253 protected LatLon(LatLon coor) { 253 /** 254 * Creates a new LatLon object for the given coordinate 255 * @param coor The coordinates to copy from. 256 */ 257 public LatLon(ILatLon coor) { 254 258 super(coor.lon(), coor.lat()); 255 259 } … … 263 267 } 264 268 265 /** 266 * Returns the latitude, i.e., the north-south position in degrees. 267 * @return the latitude 268 */ 269 @Override 269 270 public double lat() { 270 271 return y; … … 286 287 } 287 288 288 /** 289 * Returns the longitude, i.e., the east-west position in degrees. 290 * @return the longitude 291 */ 289 @Override 292 290 public double lon() { 293 291 return x; -
trunk/src/org/openstreetmap/josm/data/osm/BBox.java
r11452 r12161 7 7 8 8 import org.openstreetmap.josm.data.Bounds; 9 import org.openstreetmap.josm.data.coor.ILatLon; 9 10 import org.openstreetmap.josm.data.coor.LatLon; 10 11 import org.openstreetmap.josm.data.coor.QuadTiling; … … 85 86 */ 86 87 public BBox(Way w) { 87 w.getNodes().forEach( n -> add(n.getCoor()));88 w.getNodes().forEach(this::add); 88 89 } 89 90 … … 93 94 */ 94 95 public BBox(Node n) { 95 if (n.isLatLonKnown()) { 96 add(n.getCoor()); 97 } 96 this((ILatLon) n); 97 } 98 99 /** 100 * Create BBox for a given latlon. An invalid BBox is returned if the coordinates are not known. 101 * @param ll The lat lon position 102 */ 103 public BBox(ILatLon ll) { 104 add(ll); 105 } 106 107 /** 108 * Add a point to an existing BBox. Extends this bbox if necessary so that this.bounds(c) will return true 109 * if c is a valid LatLon instance. 110 * Kept for binary compatibility 111 * @param c a LatLon point 112 */ 113 public final void add(LatLon c) { 114 add((ILatLon) c); 98 115 } 99 116 … … 103 120 * @param c a LatLon point 104 121 */ 105 public final void add(LatLon c) { 106 if (c != null && c.isValid()) { 107 add(c.lon(), c.lat()); 108 } 122 public final void add(ILatLon c) { 123 add(c.lon(), c.lat()); 109 124 } 110 125 -
trunk/src/org/openstreetmap/josm/data/osm/INode.java
r9460 r12161 3 3 4 4 import org.openstreetmap.josm.data.coor.EastNorth; 5 import org.openstreetmap.josm.data.coor.ILatLon; 5 6 import org.openstreetmap.josm.data.coor.LatLon; 6 7 … … 9 10 * @since 4098 10 11 */ 11 public interface INode extends IPrimitive {12 public interface INode extends IPrimitive, ILatLon { 12 13 13 14 /** … … 24 25 25 26 /** 26 * Returns east/north coordinates of this node.27 * @return east/north coordinates of this node28 */29 EastNorth getEastNorth();30 31 /**32 27 * Sets east/north coordinates of this node. 33 28 * @param eastNorth east/north coordinates of this node -
trunk/src/org/openstreetmap/josm/data/osm/Node.java
r12031 r12161 15 15 import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor; 16 16 import org.openstreetmap.josm.data.osm.visitor.Visitor; 17 import org.openstreetmap.josm.data.projection.Projecti on;17 import org.openstreetmap.josm.data.projection.Projecting; 18 18 import org.openstreetmap.josm.data.projection.Projections; 19 19 import org.openstreetmap.josm.tools.CheckParameterUtil; … … 48 48 * @since 7828 49 49 */ 50 @Override 50 51 public boolean isLatLonKnown() { 52 // We cannot use default implementation - if we remove this implementation, we will break binary compatibility. 51 53 return !Double.isNaN(lat) && !Double.isNaN(lon); 52 54 } … … 81 83 @Override 82 84 public LatLon getCoor() { 83 if (!isLatLonKnown()) return null; 84 return new LatLon(lat, lon); 85 } 86 87 /** 88 * <p>Replies the projected east/north coordinates.</p> 89 * 90 * <p>Uses the {@link Main#getProjection() global projection} to project the lan/lon-coordinates. 91 * Internally caches the projected coordinates.</p> 92 * 93 * <p>Replies {@code null} if this node doesn't know lat/lon-coordinates, i.e. because it is an incomplete node. 94 * 95 * @return the east north coordinates or {@code null} 96 * @see #invalidateEastNorthCache() 97 * 98 */ 99 @Override 100 public EastNorth getEastNorth() { 101 return getEastNorth(Main.getProjection()); 102 } 103 104 /** 105 * Replies the projected east/north coordinates. 106 * <p> 107 * The result of the last conversion is cached. The cache object is used as cache key. 108 * @param projection The projection to use. 109 * @return The projected east/north coordinates 110 * @since 10827 111 */ 112 public EastNorth getEastNorth(Projection projection) { 85 if (!isLatLonKnown()) { 86 return null; 87 } else { 88 return new LatLon(lat, lon); 89 } 90 } 91 92 @Override 93 public double lat() { 94 return lat; 95 } 96 97 @Override 98 public double lon() { 99 return lon; 100 } 101 102 @Override 103 public EastNorth getEastNorth(Projecting projection) { 113 104 if (!isLatLonKnown()) return null; 114 105 -
trunk/src/org/openstreetmap/josm/data/osm/NodeData.java
r12017 r12161 41 41 } 42 42 43 private boolean isLatLonKnown() { 43 @Override 44 public double lat() { 45 return lat; 46 } 47 48 @Override 49 public double lon() { 50 return lon; 51 } 52 53 @Override 54 public boolean isLatLonKnown() { 44 55 return !Double.isNaN(lat) && !Double.isNaN(lon); 45 56 } -
trunk/src/org/openstreetmap/josm/data/osm/NodePositionComparator.java
r9880 r12161 20 20 return 0; 21 21 22 int dLat = Double.compare(n1. getCoor().lat(), n2.getCoor().lat());23 return dLat != 0 ? dLat : Double.compare(n1. getCoor().lon(), n2.getCoor().lon());22 int dLat = Double.compare(n1.lat(), n2.lat()); 23 return dLat != 0 ? dLat : Double.compare(n1.lon(), n2.lon()); 24 24 } 25 25 } -
trunk/src/org/openstreetmap/josm/data/projection/AbstractProjection.java
r12149 r12161 10 10 import org.openstreetmap.josm.data.ProjectionBounds; 11 11 import org.openstreetmap.josm.data.coor.EastNorth; 12 import org.openstreetmap.josm.data.coor.ILatLon; 12 13 import org.openstreetmap.josm.data.coor.LatLon; 13 14 import org.openstreetmap.josm.data.projection.datum.Datum; … … 114 115 115 116 @Override 116 public EastNorth latlon2eastNorth(LatLon ll) { 117 ll = datum.fromWGS84(ll); 117 public EastNorth latlon2eastNorth(ILatLon toConvert) { 118 // TODO: Use ILatLon in datum, so we don't need to wrap it here. 119 LatLon ll = datum.fromWGS84(new LatLon(toConvert)); 118 120 double[] en = proj.project(Utils.toRadians(ll.lat()), Utils.toRadians(LatLon.normalizeLon(ll.lon() - lon0 - pm))); 119 121 return new EastNorth((ellps.a * k0 * en[0] + x0) / toMeter, (ellps.a * k0 * en[1] + y0) / toMeter); … … 122 124 @Override 123 125 public LatLon eastNorth2latlon(EastNorth en) { 126 // We know it is a latlon. Nice would be to change this method return type to ILatLon 124 127 return eastNorth2latlon(en, LatLon::normalizeLon); 125 128 } … … 127 130 @Override 128 131 public LatLon eastNorth2latlonClamped(EastNorth en) { 129 LatLon ll = eastNorth2latlon(en, lon -> Utils.clamp(lon, -180, 180));132 ILatLon ll = eastNorth2latlon(en, lon -> Utils.clamp(lon, -180, 180)); 130 133 Bounds bounds = getWorldBoundsLatLon(); 131 134 return new LatLon(Utils.clamp(ll.lat(), bounds.getMinLat(), bounds.getMaxLat()), -
trunk/src/org/openstreetmap/josm/data/projection/Ellipsoid.java
r12013 r12161 7 7 package org.openstreetmap.josm.data.projection; 8 8 9 import org.openstreetmap.josm.data.coor.ILatLon; 9 10 import org.openstreetmap.josm.data.coor.LatLon; 10 11 import org.openstreetmap.josm.tools.Utils; -
trunk/src/org/openstreetmap/josm/data/projection/Projecting.java
r10805 r12161 6 6 import org.openstreetmap.josm.data.ProjectionBounds; 7 7 import org.openstreetmap.josm.data.coor.EastNorth; 8 import org.openstreetmap.josm.data.coor.ILatLon; 8 9 import org.openstreetmap.josm.data.coor.LatLon; 9 10 … … 19 20 /** 20 21 * Convert from lat/lon to easting/northing. 22 * <p> 23 * This method exists to not break binary compatibility with old plugins 21 24 * 22 25 * @param ll the geographical point to convert (in WGS84 lat/lon) 23 26 * @return the corresponding east/north coordinates 24 27 */ 25 EastNorth latlon2eastNorth(LatLon ll); 28 default EastNorth latlon2eastNorth(LatLon ll) { 29 return latlon2eastNorth((ILatLon) ll); 30 } 31 32 /** 33 * Convert from lat/lon to easting/northing. This method uses the newer {@link ILatLon} interface. 34 * 35 * @param ll the geographical point to convert (in WGS84 lat/lon) 36 * @return the corresponding east/north coordinates 37 * @since xxx 38 */ 39 EastNorth latlon2eastNorth(ILatLon ll); 26 40 27 41 /** … … 48 62 */ 49 63 Map<ProjectionBounds, Projecting> getProjectingsForArea(ProjectionBounds area); 64 65 /** 66 * Gets the object used as cache identifier when caching results of this projection. 67 * @return The object to use as cache key 68 * @since 10827 69 */ 70 default Object getCacheKey() { 71 return this; 72 } 50 73 } -
trunk/src/org/openstreetmap/josm/data/projection/Projection.java
r11858 r12161 119 119 */ 120 120 boolean switchXY(); 121 122 /**123 * Gets the object used as cache identifier when caching results of this projection.124 * @return The object to use as cache key125 * @since 10827126 */127 default Object getCacheKey() {128 return this;129 }130 121 } -
trunk/src/org/openstreetmap/josm/data/projection/ShiftedProjecting.java
r10836 r12161 7 7 import org.openstreetmap.josm.data.ProjectionBounds; 8 8 import org.openstreetmap.josm.data.coor.EastNorth; 9 import org.openstreetmap.josm.data.coor.ILatLon; 9 10 import org.openstreetmap.josm.data.coor.LatLon; 10 11 … … 29 30 30 31 @Override 31 public EastNorth latlon2eastNorth( LatLon ll) {32 public EastNorth latlon2eastNorth(ILatLon ll) { 32 33 return base.latlon2eastNorth(ll).add(offset); 33 34 } -
trunk/src/org/openstreetmap/josm/data/validation/PaintVisitor.java
r12131 r12161 3 3 4 4 import java.awt.Color; 5 import java.awt.Graphics ;5 import java.awt.Graphics2D; 6 6 import java.awt.Point; 7 7 import java.util.HashSet; … … 18 18 import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor; 19 19 import org.openstreetmap.josm.gui.MapView; 20 import org.openstreetmap.josm.gui.draw.MapViewPath; 21 import org.openstreetmap.josm.gui.draw.SymbolShape; 20 22 import org.openstreetmap.josm.tools.Utils; 21 23 … … 27 29 public class PaintVisitor extends AbstractVisitor implements ValidatorVisitor { 28 30 /** The graphics */ 29 private final Graphics g;31 private final Graphics2D g; 30 32 /** The MapView */ 31 33 private final MapView mv; … … 44 46 * @param mv The Mapview 45 47 */ 46 public PaintVisitor(Graphics g, MapView mv) {48 public PaintVisitor(Graphics2D g, MapView mv) { 47 49 this.g = g; 48 50 this.mv = mv; … … 121 123 122 124 if (!paintedPoints.contains(pp)) { 123 Point p = mv.getPoint(n);125 MapViewPath circle = new MapViewPath(mv.getState()).shapeAround(n, SymbolShape.CIRCLE, 10); 124 126 125 127 if (selected) { 126 128 g.setColor(getHighlightColor(color)); 127 g.fill Oval(p.x - 5, p.y - 5, 10, 10);129 g.fill(circle); 128 130 } 129 131 g.setColor(color); 130 g.draw Oval(p.x - 5, p.y - 5, 10, 10);132 g.draw(circle); 131 133 paintedPoints.add(pp); 132 134 } -
trunk/src/org/openstreetmap/josm/gui/MapViewState.java
r12074 r12161 20 20 import org.openstreetmap.josm.data.ProjectionBounds; 21 21 import org.openstreetmap.josm.data.coor.EastNorth; 22 import org.openstreetmap.josm.data.coor.ILatLon; 22 23 import org.openstreetmap.josm.data.coor.LatLon; 23 24 import org.openstreetmap.josm.data.osm.Node; … … 180 181 /** 181 182 * Gets the {@link MapViewPoint} for the given {@link LatLon} coordinate. 183 * <p> 184 * This method exists to not break binary compatibility with old plugins 182 185 * @param latlon the position 183 186 * @return The point for that position. … … 185 188 */ 186 189 public MapViewPoint getPointFor(LatLon latlon) { 187 return getPointFor(getProjection().latlon2eastNorth(latlon)); 190 return getPointFor((ILatLon) latlon); 191 } 192 193 /** 194 * Gets the {@link MapViewPoint} for the given {@link LatLon} coordinate. 195 * @param latlon the position 196 * @return The point for that position. 197 * @since xxx 198 */ 199 public MapViewPoint getPointFor(ILatLon latlon) { 200 try { 201 return getPointFor(Optional.ofNullable(latlon.getEastNorth(getProjection())) 202 .orElseThrow(IllegalArgumentException::new)); 203 } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) { 204 throw BugReport.intercept(e).put("latlon", latlon); 205 } 188 206 } 189 207 … … 196 214 */ 197 215 public MapViewPoint getPointFor(Node node) { 198 try { 199 return getPointFor(Optional.ofNullable(node.getEastNorth(getProjection())) 200 .orElseThrow(IllegalArgumentException::new)); 201 } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) { 202 throw BugReport.intercept(e).put("node", node); 203 } 216 return getPointFor((ILatLon) node); 204 217 } 205 218 … … 249 262 * Gets the current projection used for the MapView. 250 263 * @return The projection. 264 * @see #getProjecting() 251 265 */ 252 266 public Projection getProjection() { 253 267 return projecting.getBaseProjection(); 268 } 269 270 /** 271 * Gets the current projecting instance that is used to convert between east/north and lat/lon space. 272 * @return The projection. 273 * @since xxx 274 */ 275 public Projecting getProjecting() { 276 return projecting; 254 277 } 255 278 -
trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDataText.java
r10198 r12161 203 203 204 204 void addCoordinates(Node n) { 205 if (n. getCoor() != null) {205 if (n.isLatLonKnown()) { 206 206 add(tr("Coordinates: "), 207 Double.toString(n. getCoor().lat()), ", ",208 Double.toString(n. getCoor().lon()));207 Double.toString(n.lat()), ", ", 208 Double.toString(n.lon())); 209 209 add(tr("Coordinates (projected): "), 210 210 Double.toString(n.getEastNorth().east()), ", ", -
trunk/src/org/openstreetmap/josm/gui/draw/MapViewPath.java
r11817 r12161 9 9 10 10 import org.openstreetmap.josm.data.coor.EastNorth; 11 import org.openstreetmap.josm.data. osm.Node;11 import org.openstreetmap.josm.data.coor.ILatLon; 12 12 import org.openstreetmap.josm.gui.MapView; 13 13 import org.openstreetmap.josm.gui.MapViewState; … … 57 57 * @return this for easy chaining. 58 58 */ 59 public MapViewPath moveTo( Noden) {60 moveTo(n.getEastNorth( ));59 public MapViewPath moveTo(ILatLon n) { 60 moveTo(n.getEastNorth(state.getProjecting())); 61 61 return this; 62 62 } … … 85 85 * @return this for easy chaining. 86 86 */ 87 public MapViewPath lineTo( Noden) {88 lineTo(n.getEastNorth( ));87 public MapViewPath lineTo(ILatLon n) { 88 lineTo(n.getEastNorth(state.getProjecting())); 89 89 return this; 90 90 } … … 115 115 * @return this for easy chaining. 116 116 */ 117 public MapViewPath shapeAround( Nodep1, SymbolShape symbol, double size) {118 shapeAround(p1.getEastNorth( ), symbol, size);117 public MapViewPath shapeAround(ILatLon p1, SymbolShape symbol, double size) { 118 shapeAround(p1.getEastNorth(state.getProjecting()), symbol, size); 119 119 return this; 120 120 } … … 144 144 * @return this for easy chaining. 145 145 */ 146 public MapViewPath append(Iterable< Node> nodes, boolean connect) {146 public MapViewPath append(Iterable<? extends ILatLon> nodes, boolean connect) { 147 147 appendWay(nodes, connect, false); 148 148 return this; … … 155 155 * @return this for easy chaining. 156 156 */ 157 public MapViewPath appendClosed(Iterable< Node> nodes, boolean connect) {157 public MapViewPath appendClosed(Iterable<? extends ILatLon> nodes, boolean connect) { 158 158 appendWay(nodes, connect, true); 159 159 return this; 160 160 } 161 161 162 private void appendWay(Iterable< Node> nodes, boolean connect, boolean close) {162 private void appendWay(Iterable<? extends ILatLon> nodes, boolean connect, boolean close) { 163 163 boolean useMoveTo = !connect; 164 Nodefirst = null;165 for ( Noden : nodes) {164 ILatLon first = null; 165 for (ILatLon n : nodes) { 166 166 if (useMoveTo) { 167 167 moveTo(n); -
trunk/src/org/openstreetmap/josm/tools/Geometry.java
r11779 r12161 22 22 import org.openstreetmap.josm.command.Command; 23 23 import org.openstreetmap.josm.data.coor.EastNorth; 24 import org.openstreetmap.josm.data.coor.LatLon;25 24 import org.openstreetmap.josm.data.osm.BBox; 26 25 import org.openstreetmap.josm.data.osm.DataSet; … … 224 223 BBox bounds = new BBox(nodes.get(0)); 225 224 for (Node n: nodes) { 226 bounds.add(n .getCoor());225 bounds.add(n); 227 226 } 228 227 return bounds; … … 417 416 return p2; 418 417 else 419 return new EastNorth(p1.getX() + ldx * offset, p1.getY() + ldy *offset);418 return p1.interpolate(p2, offset); 420 419 } 421 420 … … 513 512 for (Node n : polygon) { 514 513 if (begin) { 515 path.moveTo(n. getCoor().lon(), n.getCoor().lat());514 path.moveTo(n.lon(), n.lat()); 516 515 begin = false; 517 516 } else { 518 path.lineTo(n. getCoor().lon(), n.getCoor().lat());517 path.lineTo(n.lon(), n.lat()); 519 518 } 520 519 } … … 728 727 729 728 for (int node = 1; node <= /*sic! consider last-first as well*/ nodesCount; node++) { 730 LatLon coorPrev = nodes.get(node - 1).getCoor();731 LatLon coorCurr = nodes.get(node % nodesCount).getCoor();729 Node coorPrev = nodes.get(node - 1); 730 Node coorCurr = nodes.get(node % nodesCount); 732 731 area2 += coorPrev.lon() * coorCurr.lat(); 733 732 area2 -= coorCurr.lon() * coorPrev.lat(); … … 988 987 double area = 0; 989 988 double perimeter = 0; 989 Projection useProjection = projection == null ? Main.getProjection() : projection; 990 990 991 if (!nodes.isEmpty()) { 991 992 boolean closed = nodes.get(0) == nodes.get(nodes.size() - 1); 992 993 int numSegments = closed ? nodes.size() - 1 : nodes.size(); 993 EastNorth p1 = projection == null ? nodes.get(0).getEastNorth() : projection.latlon2eastNorth(nodes.get(0).getCoor());994 EastNorth p1 = nodes.get(0).getEastNorth(useProjection); 994 995 for (int i = 1; i <= numSegments; i++) { 995 996 final Node node = nodes.get(i == numSegments ? 0 : i); 996 final EastNorth p2 = projection == null ? node.getEastNorth() : projection.latlon2eastNorth(node.getCoor());997 final EastNorth p2 = node.getEastNorth(useProjection); 997 998 if (p1 != null && p2 != null) { 998 999 area += p1.east() * p2.north() - p2.east() * p1.north();
Note:
See TracChangeset
for help on using the changeset viewer.