Changeset 28415 in osm for applications/editors


Ignore:
Timestamp:
2012-05-30T04:39:19+02:00 (12 years ago)
Author:
joshdoe
Message:

Support EastNorth and LatLon for coordinates, and rename converter class

File:
1 moved

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/jts/src/org/openstreetmap/josm/plugins/jts/JTSConverter.java

    r28379 r28415  
    44import com.vividsolutions.jts.geom.impl.CoordinateArraySequence;
    55import java.util.List;
    6 import org.openstreetmap.josm.data.coor.LatLon;
    76import org.openstreetmap.josm.data.osm.Node;
    87import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    1312 * Methods to convert JOSM geometry to JTS geometry
    1413 */
    15 public final class JTSUtils {
     14public 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    }
    1624
    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    }
    1938
    20     public OsmPrecisionModel getPrecisionModel() {
    21         return osmPrecisionModel;
     39    public PrecisionModel getPrecisionModel() {
     40        return precisionModel;
    2241    }
    2342
    2443    public GeometryFactory getGeometryFactory() {
    25         return osmGeometryFactory;
     44        return geometryFactory;
    2645    }
    2746
     
    3857
    3958    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());
    4263    }
    4364
Note: See TracChangeset for help on using the changeset viewer.