get JTS geometry from OSMElements
This commit is contained in:
parent
424f44ba12
commit
e9d8cdd329
@ -6,5 +6,6 @@
|
|||||||
<classpathentry exported="true" kind="lib" path="/vtm-libs/extras/jackson-core-2.1.4.jar"/>
|
<classpathentry exported="true" kind="lib" path="/vtm-libs/extras/jackson-core-2.1.4.jar"/>
|
||||||
<classpathentry exported="true" kind="lib" path="/vtm-libs/extras/osmosis-osm-binary-0.43.jar"/>
|
<classpathentry exported="true" kind="lib" path="/vtm-libs/extras/osmosis-osm-binary-0.43.jar"/>
|
||||||
<classpathentry exported="true" kind="lib" path="/vtm-libs/extras/protobuf-java-2.4.1.jar" sourcepath="/home/jeff/.m2/repository/com/google/protobuf/protobuf-java/2.4.1/protobuf-java-2.4.1-sources.jar"/>
|
<classpathentry exported="true" kind="lib" path="/vtm-libs/extras/protobuf-java-2.4.1.jar" sourcepath="/home/jeff/.m2/repository/com/google/protobuf/protobuf-java/2.4.1/protobuf-java-2.4.1-sources.jar"/>
|
||||||
|
<classpathentry kind="lib" path="/vtm-libs/libs/jts-1.13.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
@ -18,6 +18,8 @@ package org.oscim.utils.osm;
|
|||||||
|
|
||||||
import org.oscim.core.TagSet;
|
import org.oscim.core.TagSet;
|
||||||
|
|
||||||
|
import com.vividsolutions.jts.geom.Geometry;
|
||||||
|
|
||||||
public abstract class OSMElement {
|
public abstract class OSMElement {
|
||||||
|
|
||||||
public final TagSet tags;
|
public final TagSet tags;
|
||||||
@ -59,4 +61,5 @@ public abstract class OSMElement {
|
|||||||
return "?" + id;
|
return "?" + id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract Geometry toJts();
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,6 @@ public class OSMMember {
|
|||||||
RELATIOM
|
RELATIOM
|
||||||
}
|
}
|
||||||
|
|
||||||
static final boolean useDebugLabels = true;
|
|
||||||
|
|
||||||
public final String role;
|
public final String role;
|
||||||
public final OSMElement member;
|
public final OSMElement member;
|
||||||
|
|
||||||
|
@ -18,8 +18,9 @@ package org.oscim.utils.osm;
|
|||||||
|
|
||||||
import org.oscim.core.TagSet;
|
import org.oscim.core.TagSet;
|
||||||
|
|
||||||
|
import com.vividsolutions.jts.geom.Geometry;
|
||||||
|
|
||||||
public class OSMNode extends OSMElement {
|
public class OSMNode extends OSMElement {
|
||||||
//public static EMPTY_NODE = new OSMNode()
|
|
||||||
|
|
||||||
public final double lat;
|
public final double lat;
|
||||||
public final double lon;
|
public final double lon;
|
||||||
@ -35,4 +36,8 @@ public class OSMNode extends OSMElement {
|
|||||||
return "n" + id;
|
return "n" + id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Geometry toJts() {
|
||||||
|
return null; //bnew Point(new Coordinate(lat, lon), null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,8 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.oscim.core.TagSet;
|
import org.oscim.core.TagSet;
|
||||||
|
|
||||||
|
import com.vividsolutions.jts.geom.Geometry;
|
||||||
|
|
||||||
public class OSMRelation extends OSMElement {
|
public class OSMRelation extends OSMElement {
|
||||||
|
|
||||||
public final List<OSMMember> relationMembers;
|
public final List<OSMMember> relationMembers;
|
||||||
@ -38,4 +40,8 @@ public class OSMRelation extends OSMElement {
|
|||||||
return "r" + id;
|
return "r" + id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Geometry toJts() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,11 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.oscim.core.TagSet;
|
import org.oscim.core.TagSet;
|
||||||
|
|
||||||
|
import com.vividsolutions.jts.geom.CoordinateSequence;
|
||||||
|
import com.vividsolutions.jts.geom.Geometry;
|
||||||
|
import com.vividsolutions.jts.geom.LineString;
|
||||||
|
import com.vividsolutions.jts.geom.impl.PackedCoordinateSequenceFactory;
|
||||||
|
|
||||||
public class OSMWay extends OSMElement {
|
public class OSMWay extends OSMElement {
|
||||||
|
|
||||||
public final List<OSMNode> nodes;
|
public final List<OSMNode> nodes;
|
||||||
@ -39,4 +44,15 @@ public class OSMWay extends OSMElement {
|
|||||||
return "w" + id;
|
return "w" + id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Geometry toJts() {
|
||||||
|
double[] coords = new double[nodes.size() * 2];
|
||||||
|
int i = 0;
|
||||||
|
for (OSMNode n : nodes) {
|
||||||
|
coords[i++] = n.lon;
|
||||||
|
coords[i++] = n.lat;
|
||||||
|
}
|
||||||
|
|
||||||
|
CoordinateSequence c = PackedCoordinateSequenceFactory.DOUBLE_FACTORY.create(coords, 2);
|
||||||
|
return new LineString(c, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user