Changeset 28415 in osm for applications/editors/josm/plugins/jts/src/org/openstreetmap
- Timestamp:
- 2012-05-30T04:39:19+02:00 (13 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/jts/src/org/openstreetmap/josm/plugins/jts/JTSConverter.java
r28379 r28415 4 4 import com.vividsolutions.jts.geom.impl.CoordinateArraySequence; 5 5 import java.util.List; 6 import org.openstreetmap.josm.data.coor.LatLon;7 6 import org.openstreetmap.josm.data.osm.Node; 8 7 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 13 12 * Methods to convert JOSM geometry to JTS geometry 14 13 */ 15 public final class JTSUtils { 14 public class JTSConverter { 15 private PrecisionModel precisionModel; 16 private GeometryFactory geometryFactory; 17 private boolean useEastNorth; 18 /** 19 * Conversions will use latitude/longitude for coordinates 20 */ 21 public JTSConverter() { 22 this(false); 23 } 16 24 17 public final OsmPrecisionModel osmPrecisionModel = new OsmPrecisionModel(); 18 public final GeometryFactory osmGeometryFactory = new GeometryFactory(getPrecisionModel()); 25 /** 26 * Conversions will use LatLon if useEastNorth is false, otherwise EastNorth 27 * (the currently selected projection) will be used for coordinates. 28 * @param useEastNorth 29 */ 30 public JTSConverter(boolean useEastNorth) { 31 this.useEastNorth = useEastNorth; 32 if (useEastNorth) 33 precisionModel = new PrecisionModel(); 34 else 35 precisionModel = new OsmPrecisionModel(); 36 geometryFactory = new GeometryFactory(precisionModel); 37 } 19 38 20 public OsmPrecisionModel getPrecisionModel() {21 return osmPrecisionModel;39 public PrecisionModel getPrecisionModel() { 40 return precisionModel; 22 41 } 23 42 24 43 public GeometryFactory getGeometryFactory() { 25 return osmGeometryFactory;44 return geometryFactory; 26 45 } 27 46 … … 38 57 39 58 public Coordinate convertNodeToCoordinate(Node node) { 40 LatLon ll = node.getCoor(); 41 return new Coordinate(ll.lon(), ll.lat()); 59 if (useEastNorth) 60 return new Coordinate(node.getEastNorth().getX(), node.getEastNorth().getY()); 61 else 62 return new Coordinate(node.getCoor().getX(), node.getCoor().getY()); 42 63 } 43 64
Note:
See TracChangeset
for help on using the changeset viewer.