consistent formatting
This commit is contained in:
@@ -5,7 +5,7 @@ import java.util.ArrayList;
|
||||
/**
|
||||
* Triangulates a polygon into triangles - duh. Doesn't handle
|
||||
* holes in polys
|
||||
*
|
||||
*
|
||||
* @author Public Source from FlipCode
|
||||
*/
|
||||
public class Triangulator {
|
||||
@@ -26,7 +26,7 @@ public class Triangulator {
|
||||
|
||||
/**
|
||||
* Add a point describing the polygon to be triangulated
|
||||
*
|
||||
*
|
||||
* @param x The x coordinate of the point
|
||||
* @param y the y coordinate of the point
|
||||
*/
|
||||
@@ -36,7 +36,7 @@ public class Triangulator {
|
||||
|
||||
/**
|
||||
* Cause the triangulator to split the polygon
|
||||
*
|
||||
*
|
||||
* @return True if we managed the task
|
||||
*/
|
||||
public boolean triangulate() {
|
||||
@@ -48,7 +48,7 @@ public class Triangulator {
|
||||
|
||||
/**
|
||||
* Get a count of the number of triangles produced
|
||||
*
|
||||
*
|
||||
* @return The number of triangles produced
|
||||
*/
|
||||
public int getTriangleCount() {
|
||||
@@ -60,7 +60,7 @@ public class Triangulator {
|
||||
|
||||
/**
|
||||
* Get a point on a specified generated triangle
|
||||
*
|
||||
*
|
||||
* @param tri The index of the triangle to interegate
|
||||
* @param i The index of the point within the triangle to retrieve
|
||||
* (0 - 2)
|
||||
@@ -76,7 +76,7 @@ public class Triangulator {
|
||||
/**
|
||||
* Find the area of a polygon defined by the series of points
|
||||
* in the list
|
||||
*
|
||||
*
|
||||
* @param contour The list of points defined the contour of the polygon
|
||||
* (Vector2f)
|
||||
* @return The area of the polygon defined
|
||||
@@ -91,7 +91,7 @@ public class Triangulator {
|
||||
Point contourQ = contour.get(q);
|
||||
|
||||
A += contourP.getX() * contourQ.getY() - contourQ.getX()
|
||||
* contourP.getY();
|
||||
* contourP.getY();
|
||||
}
|
||||
return A * 0.5f;
|
||||
}
|
||||
@@ -99,7 +99,7 @@ public class Triangulator {
|
||||
/**
|
||||
* Check if the point P is inside the triangle defined by
|
||||
* the points A,B,C
|
||||
*
|
||||
*
|
||||
* @param Ax Point A x-coordinate
|
||||
* @param Ay Point A y-coordinate
|
||||
* @param Bx Point B x-coordinate
|
||||
@@ -111,7 +111,7 @@ public class Triangulator {
|
||||
* @return True if the point specified is within the triangle
|
||||
*/
|
||||
private static boolean insideTriangle(float Ax, float Ay, float Bx,
|
||||
float By, float Cx, float Cy, float Px, float Py) {
|
||||
float By, float Cx, float Cy, float Px, float Py) {
|
||||
float ax, ay, bx, by, cx, cy, apx, apy, bpx, bpy, cpx, cpy;
|
||||
float cCROSSap, bCROSScp, aCROSSbp;
|
||||
|
||||
@@ -138,7 +138,7 @@ public class Triangulator {
|
||||
/**
|
||||
* Cut a the contour and add a triangle into V to describe the
|
||||
* location of the cut
|
||||
*
|
||||
*
|
||||
* @param contour The list of points defining the polygon
|
||||
* @param u The index of the first point
|
||||
* @param v The index of the second point
|
||||
@@ -148,7 +148,7 @@ public class Triangulator {
|
||||
* @return True if a triangle was found
|
||||
*/
|
||||
private static boolean snip(PointList contour, int u, int v, int w, int n,
|
||||
int[] V) {
|
||||
int[] V) {
|
||||
int p;
|
||||
float Ax, Ay, Bx, By, Cx, Cy, Px, Py;
|
||||
|
||||
@@ -183,7 +183,7 @@ public class Triangulator {
|
||||
|
||||
/**
|
||||
* Process a list of points defining a polygon
|
||||
*
|
||||
*
|
||||
* @param contour The list of points describing the polygon
|
||||
* @param result The list of points describing the triangles. Groups
|
||||
* of 3 describe each triangle
|
||||
@@ -263,7 +263,7 @@ public class Triangulator {
|
||||
|
||||
/**
|
||||
* A single point handled by the triangulator
|
||||
*
|
||||
*
|
||||
* @author Kevin Glass
|
||||
*/
|
||||
private class Point {
|
||||
@@ -274,7 +274,7 @@ public class Triangulator {
|
||||
|
||||
/**
|
||||
* Create a new point
|
||||
*
|
||||
*
|
||||
* @param x The x coordindate of the point
|
||||
* @param y The y coordindate of the point
|
||||
*/
|
||||
@@ -285,7 +285,7 @@ public class Triangulator {
|
||||
|
||||
/**
|
||||
* Get the x coordinate of the point
|
||||
*
|
||||
*
|
||||
* @return The x coordinate of the point
|
||||
*/
|
||||
public float getX() {
|
||||
@@ -294,7 +294,7 @@ public class Triangulator {
|
||||
|
||||
/**
|
||||
* Get the y coordinate of the point
|
||||
*
|
||||
*
|
||||
* @return The y coordinate of the point
|
||||
*/
|
||||
public float getY() {
|
||||
@@ -303,7 +303,7 @@ public class Triangulator {
|
||||
|
||||
/**
|
||||
* Convert this point into a float array
|
||||
*
|
||||
*
|
||||
* @return The contents of this point as a float array
|
||||
*/
|
||||
public float[] toArray() {
|
||||
@@ -313,7 +313,7 @@ public class Triangulator {
|
||||
|
||||
/**
|
||||
* A list of type <code>Point</code>
|
||||
*
|
||||
*
|
||||
* @author Kevin Glass
|
||||
*/
|
||||
private class PointList {
|
||||
@@ -328,7 +328,7 @@ public class Triangulator {
|
||||
|
||||
/**
|
||||
* Add a point to the list
|
||||
*
|
||||
*
|
||||
* @param point The point to add
|
||||
*/
|
||||
public void add(Point point) {
|
||||
@@ -346,7 +346,7 @@ public class Triangulator {
|
||||
|
||||
/**
|
||||
* Get the size of the list
|
||||
*
|
||||
*
|
||||
* @return The size of the list
|
||||
*/
|
||||
public int size() {
|
||||
@@ -355,7 +355,7 @@ public class Triangulator {
|
||||
|
||||
/**
|
||||
* Get a point a specific index in the list
|
||||
*
|
||||
*
|
||||
* @param i The index of the point to retrieve
|
||||
* @return The point
|
||||
*/
|
||||
|
||||
@@ -27,7 +27,7 @@ public class OSMData {
|
||||
private final Collection<OSMRelation> relations;
|
||||
|
||||
public OSMData(Collection<Bound> bounds, Collection<OSMNode> nodes,
|
||||
Collection<OSMWay> ways, Collection<OSMRelation> relations) {
|
||||
Collection<OSMWay> ways, Collection<OSMRelation> relations) {
|
||||
|
||||
this.bounds = bounds;
|
||||
this.nodes = nodes;
|
||||
|
||||
@@ -15,11 +15,12 @@
|
||||
package org.oscim.utils.osm;
|
||||
|
||||
public class OSMMember {
|
||||
public enum MemberType{
|
||||
public enum MemberType {
|
||||
NODE,
|
||||
WAY,
|
||||
RELATIOM
|
||||
}
|
||||
|
||||
static final boolean useDebugLabels = true;
|
||||
|
||||
public final String role;
|
||||
|
||||
@@ -28,7 +28,7 @@ public class OSMRelation extends OSMElement {
|
||||
public OSMRelation(TagSet tags, long id, int initialMemberSize) {
|
||||
super(tags, id);
|
||||
this.relationMembers =
|
||||
new ArrayList<OSMMember>(initialMemberSize);
|
||||
new ArrayList<OSMMember>(initialMemberSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,7 +29,7 @@ public class OSMWay extends OSMElement {
|
||||
|
||||
public boolean isClosed() {
|
||||
return nodes.size() > 0 &&
|
||||
nodes.get(0).equals(nodes.get(nodes.size() - 1));
|
||||
nodes.get(0).equals(nodes.get(nodes.size() - 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,9 +16,6 @@ import org.oscim.utils.osm.OSMNode;
|
||||
import org.oscim.utils.osm.OSMRelation;
|
||||
import org.oscim.utils.osm.OSMWay;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Class that reads and parses binary files and sends the contained entities to
|
||||
* the sink.
|
||||
@@ -205,32 +202,31 @@ public class OsmPbfParser extends BinaryParser {
|
||||
for (int j = 0; j < tagCnt; j++)
|
||||
tags.add(new Tag(getStringById(i.getKeys(j)), getStringById(i.getVals(j))));
|
||||
|
||||
|
||||
long id = i.getId();
|
||||
|
||||
long lastMid = 0;
|
||||
List<OSMMember> nodes = new ArrayList<OSMMember>();
|
||||
int memberCnt = i.getMemidsCount();
|
||||
|
||||
// for (int j = 0; j < memberCnt; j++) {
|
||||
// long mid = lastMid + i.getMemids(j);
|
||||
// lastMid = mid;
|
||||
// String role = getStringById(i.getRolesSid(j));
|
||||
//
|
||||
// Osmformat.Relation.MemberType t = i.getTypes(j);
|
||||
//
|
||||
// if (t == Osmformat.Relation.MemberType.NODE) {
|
||||
// etype = EntityType.Node;
|
||||
// } else if (t == Osmformat.Relation.MemberType.WAY) {
|
||||
// etype = EntityType.Way;
|
||||
// } else if (t == Osmformat.Relation.MemberType.RELATION) {
|
||||
// etype = EntityType.Relation;
|
||||
// } else {
|
||||
// assert false; // TODO; Illegal file?
|
||||
// }
|
||||
//
|
||||
// nodes.add(new OSMMember(mid, etype, role));
|
||||
// }
|
||||
// for (int j = 0; j < memberCnt; j++) {
|
||||
// long mid = lastMid + i.getMemids(j);
|
||||
// lastMid = mid;
|
||||
// String role = getStringById(i.getRolesSid(j));
|
||||
//
|
||||
// Osmformat.Relation.MemberType t = i.getTypes(j);
|
||||
//
|
||||
// if (t == Osmformat.Relation.MemberType.NODE) {
|
||||
// etype = EntityType.Node;
|
||||
// } else if (t == Osmformat.Relation.MemberType.WAY) {
|
||||
// etype = EntityType.Way;
|
||||
// } else if (t == Osmformat.Relation.MemberType.RELATION) {
|
||||
// etype = EntityType.Relation;
|
||||
// } else {
|
||||
// assert false; // TODO; Illegal file?
|
||||
// }
|
||||
//
|
||||
// nodes.add(new OSMMember(mid, etype, role));
|
||||
// }
|
||||
|
||||
// long id, int version, TimestampContainer timestampContainer,
|
||||
// OsmUser user,
|
||||
@@ -246,7 +242,7 @@ public class OsmPbfParser extends BinaryParser {
|
||||
// tmp = new Relation(new CommonEntityData(id, NOVERSION, NODATE, OsmUser.NONE,
|
||||
// NOCHANGESET, tags), nodes);
|
||||
// }
|
||||
// sink.process(new RelationContainer(tmp));
|
||||
// sink.process(new RelationContainer(tmp));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,43 +277,42 @@ public class OsmPbfParser extends BinaryParser {
|
||||
|
||||
public OSMData getData() {
|
||||
|
||||
// for (Entry<OSMRelation, List<TmpRelation>> entry : relationMembersForRelation
|
||||
// .entrySet()) {
|
||||
//
|
||||
// OSMRelation relation = entry.getKey();
|
||||
//
|
||||
// for (TmpRelation member : entry.getValue()) {
|
||||
//
|
||||
// OSMElement memberObject = null;
|
||||
//
|
||||
// if ("node".equals(member)) {
|
||||
// memberObject = nodesById.get(member.id);
|
||||
// } else if ("way".equals(member)) {
|
||||
// memberObject = waysById.get(member.id);
|
||||
// } else if ("relation".equals(member)) {
|
||||
// memberObject = relationsById.get(member.id);
|
||||
// } else {
|
||||
// // log("missing relation " + member.id);
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// if (memberObject != null) {
|
||||
// OSMMember ownMember = new OSMMember(member.role,
|
||||
// memberObject);
|
||||
//
|
||||
// relation.relationMembers.add(ownMember);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// for (Entry<OSMRelation, List<TmpRelation>> entry : relationMembersForRelation
|
||||
// .entrySet()) {
|
||||
//
|
||||
// OSMRelation relation = entry.getKey();
|
||||
//
|
||||
// for (TmpRelation member : entry.getValue()) {
|
||||
//
|
||||
// OSMElement memberObject = null;
|
||||
//
|
||||
// if ("node".equals(member)) {
|
||||
// memberObject = nodesById.get(member.id);
|
||||
// } else if ("way".equals(member)) {
|
||||
// memberObject = waysById.get(member.id);
|
||||
// } else if ("relation".equals(member)) {
|
||||
// memberObject = relationsById.get(member.id);
|
||||
// } else {
|
||||
// // log("missing relation " + member.id);
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// if (memberObject != null) {
|
||||
// OSMMember ownMember = new OSMMember(member.role,
|
||||
// memberObject);
|
||||
//
|
||||
// relation.relationMembers.add(ownMember);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// give up references to original collections
|
||||
|
||||
ArrayList<OSMWay> ways = new ArrayList<OSMWay> (mWayMap.values());
|
||||
ArrayList<OSMNode> nodes= new ArrayList<OSMNode> (mNodeMap.values());
|
||||
ArrayList<OSMWay> ways = new ArrayList<OSMWay>(mWayMap.values());
|
||||
ArrayList<OSMNode> nodes = new ArrayList<OSMNode>(mNodeMap.values());
|
||||
|
||||
Log.d("..", "nodes: " + nodes.size() + " ways: " + ways.size());
|
||||
|
||||
return new OSMData(null, nodes, ways, null);
|
||||
return new OSMData(null, nodes, ways, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.oscim.utils.osm.OSMData;
|
||||
|
||||
public class OsmPbfReader {
|
||||
|
||||
public static OSMData process(InputStream is){
|
||||
public static OSMData process(InputStream is) {
|
||||
OsmPbfParser parser = new OsmPbfParser();
|
||||
|
||||
try {
|
||||
|
||||
@@ -46,7 +46,7 @@ import com.fasterxml.jackson.core.JsonParseException;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonToken;
|
||||
|
||||
public class OverpassAPIReader {
|
||||
public class OverpassAPIReader {
|
||||
private static final String OVERPASS_API = "http://city.informatik.uni-bremen.de/oapi/interpreter";
|
||||
private static final int RESPONSECODE_OK = 200;
|
||||
|
||||
@@ -75,7 +75,7 @@ public class OverpassAPIReader {
|
||||
|
||||
/**
|
||||
* Creates a new instance with the specified geographical coordinates.
|
||||
*
|
||||
*
|
||||
* @param left
|
||||
* The longitude marking the left edge of the bounding box.
|
||||
* @param right
|
||||
@@ -89,12 +89,12 @@ public class OverpassAPIReader {
|
||||
* http://www.openstreetmap.org/api/0.5).
|
||||
*/
|
||||
public OverpassAPIReader(final double left, final double right,
|
||||
final double top, final double bottom, final String baseUrl,
|
||||
final String query) {
|
||||
final double top, final double bottom, final String baseUrl,
|
||||
final String query) {
|
||||
|
||||
String bbox = "(" + Math.min(top, bottom) + "," + Math.min(left, right)
|
||||
+ "," + Math.max(top, bottom) + "," + Math.max(left, right)
|
||||
+ ")";
|
||||
+ "," + Math.max(top, bottom) + "," + Math.max(left, right)
|
||||
+ ")";
|
||||
|
||||
this.query = query.replaceAll("\\{\\{bbox\\}\\}", bbox);
|
||||
|
||||
@@ -103,7 +103,7 @@ public class OverpassAPIReader {
|
||||
/**
|
||||
* Open a connection to the given url and return a reader on the input
|
||||
* stream from that connection.
|
||||
*
|
||||
*
|
||||
* @param pUrlStr
|
||||
* The exact url to connect to.
|
||||
* @return An reader reading the input stream (servers answer) or
|
||||
@@ -120,7 +120,7 @@ public class OverpassAPIReader {
|
||||
myActiveConnection = (HttpURLConnection) url.openConnection();
|
||||
|
||||
myActiveConnection.setRequestProperty("Accept-Encoding",
|
||||
"gzip, deflate");
|
||||
"gzip, deflate");
|
||||
|
||||
responseCode = myActiveConnection.getResponseCode();
|
||||
|
||||
@@ -132,11 +132,11 @@ public class OverpassAPIReader {
|
||||
|
||||
if (apiErrorMessage != null) {
|
||||
message = "Received API HTTP response code " + responseCode
|
||||
+ " with message \"" + apiErrorMessage
|
||||
+ "\" for URL \"" + pUrlStr + "\".";
|
||||
+ " with message \"" + apiErrorMessage
|
||||
+ "\" for URL \"" + pUrlStr + "\".";
|
||||
} else {
|
||||
message = "Received API HTTP response code " + responseCode
|
||||
+ " for URL \"" + pUrlStr + "\".";
|
||||
+ " for URL \"" + pUrlStr + "\".";
|
||||
}
|
||||
|
||||
throw new IOException(message);
|
||||
@@ -151,7 +151,7 @@ public class OverpassAPIReader {
|
||||
responseStream = new GZIPInputStream(responseStream);
|
||||
} else if (encoding != null && encoding.equalsIgnoreCase("deflate")) {
|
||||
responseStream = new InflaterInputStream(responseStream,
|
||||
new Inflater(true));
|
||||
new Inflater(true));
|
||||
}
|
||||
|
||||
return responseStream;
|
||||
@@ -168,12 +168,12 @@ public class OverpassAPIReader {
|
||||
private Map<Long, OSMWay> waysById = new HashMap<Long, OSMWay>();
|
||||
private Map<Long, OSMRelation> relationsById = new HashMap<Long, OSMRelation>();
|
||||
private Map<OSMRelation, List<TmpRelation>> relationMembersForRelation =
|
||||
new HashMap<OSMRelation, List<TmpRelation>>();
|
||||
new HashMap<OSMRelation, List<TmpRelation>>();
|
||||
|
||||
private final Collection<OSMNode> ownNodes = new ArrayList<OSMNode>(10000);
|
||||
private final Collection<OSMWay> ownWays = new ArrayList<OSMWay>(1000);
|
||||
private final Collection<OSMRelation> ownRelations = new ArrayList<OSMRelation>(
|
||||
100);
|
||||
100);
|
||||
|
||||
public void parse(InputStream in) throws IOException {
|
||||
JsonFactory jsonFactory = new JsonFactory();
|
||||
@@ -208,7 +208,7 @@ public class OverpassAPIReader {
|
||||
}
|
||||
|
||||
private void parseNode(JsonParser jp) throws JsonParseException,
|
||||
IOException {
|
||||
IOException {
|
||||
|
||||
long id = 0;
|
||||
double lat = 0, lon = 0;
|
||||
@@ -274,7 +274,7 @@ public class OverpassAPIReader {
|
||||
}
|
||||
|
||||
private void parseRelation(JsonParser jp) throws JsonParseException,
|
||||
IOException {
|
||||
IOException {
|
||||
|
||||
long id = 0;
|
||||
TagSet tags = TagSet.EMPTY_TAG_SET;
|
||||
@@ -318,22 +318,21 @@ public class OverpassAPIReader {
|
||||
}
|
||||
|
||||
private static TagSet parseTags(JsonParser jp) throws JsonParseException,
|
||||
IOException {
|
||||
IOException {
|
||||
|
||||
TagSet tags = null;
|
||||
|
||||
|
||||
while (jp.nextToken() != JsonToken.END_OBJECT) {
|
||||
String key = jp.getCurrentName();
|
||||
jp.nextToken();
|
||||
String val = jp.getText();
|
||||
if (tags== null)
|
||||
tags= new TagSet(4);
|
||||
if (tags == null)
|
||||
tags = new TagSet(4);
|
||||
|
||||
tags.add(new Tag(key, val, false));
|
||||
|
||||
}
|
||||
if (tags== null)
|
||||
if (tags == null)
|
||||
return TagSet.EMPTY_TAG_SET;
|
||||
|
||||
return tags;
|
||||
@@ -343,7 +342,6 @@ public class OverpassAPIReader {
|
||||
System.out.println(msg);
|
||||
}
|
||||
|
||||
|
||||
public OSMData getData() {
|
||||
|
||||
String encoded;
|
||||
@@ -374,7 +372,7 @@ public class OverpassAPIReader {
|
||||
}
|
||||
|
||||
for (Entry<OSMRelation, List<TmpRelation>> entry : relationMembersForRelation
|
||||
.entrySet()) {
|
||||
.entrySet()) {
|
||||
|
||||
OSMRelation relation = entry.getKey();
|
||||
|
||||
@@ -395,14 +393,14 @@ public class OverpassAPIReader {
|
||||
|
||||
if (memberObject != null) {
|
||||
OSMMember ownMember = new OSMMember(member.role,
|
||||
memberObject);
|
||||
memberObject);
|
||||
|
||||
relation.relationMembers.add(ownMember);
|
||||
}
|
||||
}
|
||||
}
|
||||
log("nodes: " + ownNodes.size() + " ways: " + ownWays.size()
|
||||
+ " relations: " + ownRelations.size());
|
||||
+ " relations: " + ownRelations.size());
|
||||
|
||||
// give up references to original collections
|
||||
nodesById = null;
|
||||
|
||||
@@ -75,14 +75,14 @@ abstract class Geometry implements Serializable {
|
||||
static final int GEOMETRYCOLLECTION = 7;
|
||||
|
||||
static final String[] ALLTYPES = new String[] {
|
||||
"", // internally used LinearRing does not have any text in front of
|
||||
// it
|
||||
"POINT", "LINESTRING", "POLYGON", "MULTIPOINT", "MULTILINESTRING",
|
||||
"MULTIPOLYGON", "GEOMETRYCOLLECTION" };
|
||||
"", // internally used LinearRing does not have any text in front of
|
||||
// it
|
||||
"POINT", "LINESTRING", "POLYGON", "MULTIPOINT", "MULTILINESTRING",
|
||||
"MULTIPOLYGON", "GEOMETRYCOLLECTION" };
|
||||
|
||||
/**
|
||||
* The Text representations of the geometry types
|
||||
*
|
||||
*
|
||||
* @param type
|
||||
* ...
|
||||
* @return ...
|
||||
@@ -125,7 +125,7 @@ abstract class Geometry implements Serializable {
|
||||
|
||||
/**
|
||||
* Parse a SRID value, anything <= 0 is unknown
|
||||
*
|
||||
*
|
||||
* @param srid
|
||||
* ...
|
||||
* @return ...
|
||||
@@ -140,7 +140,7 @@ abstract class Geometry implements Serializable {
|
||||
|
||||
/**
|
||||
* Constructor for subclasses
|
||||
*
|
||||
*
|
||||
* @param type
|
||||
* has to be given by all subclasses.
|
||||
*/
|
||||
@@ -162,30 +162,30 @@ abstract class Geometry implements Serializable {
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return (other != null) && (other instanceof Geometry)
|
||||
&& equals((Geometry) other);
|
||||
&& equals((Geometry) other);
|
||||
}
|
||||
|
||||
/**
|
||||
* geometry specific equals implementation - only defined for non-null
|
||||
* values
|
||||
*
|
||||
*
|
||||
* @param other
|
||||
* ...
|
||||
* @return ...
|
||||
*/
|
||||
public boolean equals(Geometry other) {
|
||||
return (other != null) && (this.dimension == other.dimension)
|
||||
&& (this.type == other.type) && (this.srid == other.srid)
|
||||
&& (this.haveMeasure == other.haveMeasure)
|
||||
&& other.getClass().equals(this.getClass())
|
||||
&& this.equalsintern(other);
|
||||
&& (this.type == other.type) && (this.srid == other.srid)
|
||||
&& (this.haveMeasure == other.haveMeasure)
|
||||
&& other.getClass().equals(this.getClass())
|
||||
&& this.equalsintern(other);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether test coordinates for geometry - subclass specific code
|
||||
* Implementors can assume that dimensin, type, srid
|
||||
* and haveMeasure are equal, other != null and other is the same subclass.
|
||||
*
|
||||
*
|
||||
* @param other
|
||||
* ...
|
||||
* @return ...
|
||||
@@ -194,14 +194,14 @@ abstract class Geometry implements Serializable {
|
||||
|
||||
/**
|
||||
* Return the number of Points of the geometry
|
||||
*
|
||||
*
|
||||
* @return ...
|
||||
*/
|
||||
abstract int numPoints();
|
||||
|
||||
/**
|
||||
* Get the nth Point of the geometry
|
||||
*
|
||||
*
|
||||
* @param n
|
||||
* the index of the point, from 0 to numPoints()-1;
|
||||
* @throws ArrayIndexOutOfBoundsException
|
||||
@@ -222,7 +222,7 @@ abstract class Geometry implements Serializable {
|
||||
|
||||
/**
|
||||
* The OGIS geometry type number of this geometry.
|
||||
*
|
||||
*
|
||||
* @return ...
|
||||
*/
|
||||
int getType() {
|
||||
@@ -231,7 +231,7 @@ abstract class Geometry implements Serializable {
|
||||
|
||||
/**
|
||||
* Return the Type as String
|
||||
*
|
||||
*
|
||||
* @return ...
|
||||
*/
|
||||
String getTypeString() {
|
||||
@@ -240,7 +240,7 @@ abstract class Geometry implements Serializable {
|
||||
|
||||
/**
|
||||
* Returns whether we have a measure
|
||||
*
|
||||
*
|
||||
* @return ....
|
||||
*/
|
||||
boolean isMeasured() {
|
||||
@@ -251,7 +251,7 @@ abstract class Geometry implements Serializable {
|
||||
* Queries the number of geometric dimensions of this geometry. This does
|
||||
* not include measures, as opposed to the
|
||||
* server.
|
||||
*
|
||||
*
|
||||
* @return The dimensionality (eg, 2D or 3D) of this geometry.
|
||||
*/
|
||||
int getDimension() {
|
||||
@@ -260,7 +260,7 @@ abstract class Geometry implements Serializable {
|
||||
|
||||
/**
|
||||
* The OGIS geometry type number of this geometry.
|
||||
*
|
||||
*
|
||||
* @return ...
|
||||
*/
|
||||
int getSrid() {
|
||||
@@ -270,7 +270,7 @@ abstract class Geometry implements Serializable {
|
||||
/**
|
||||
* Recursively sets the srid on this geometry and all contained
|
||||
* subgeometries
|
||||
*
|
||||
*
|
||||
* @param srid
|
||||
* ...
|
||||
*/
|
||||
@@ -293,7 +293,7 @@ abstract class Geometry implements Serializable {
|
||||
/**
|
||||
* Render the WKT version of this Geometry (without SRID) into the given
|
||||
* StringBuffer.
|
||||
*
|
||||
*
|
||||
* @param sb
|
||||
* ...
|
||||
* @param putM
|
||||
@@ -314,7 +314,7 @@ abstract class Geometry implements Serializable {
|
||||
/**
|
||||
* Render the WKT without the type name, but including the brackets into the
|
||||
* StringBuffer
|
||||
*
|
||||
*
|
||||
* @param sb
|
||||
* ...
|
||||
*/
|
||||
@@ -327,7 +327,7 @@ abstract class Geometry implements Serializable {
|
||||
/**
|
||||
* Render the "inner" part of the WKT (inside the brackets) into the
|
||||
* StringBuffer.
|
||||
*
|
||||
*
|
||||
* @param SB
|
||||
* ...
|
||||
*/
|
||||
@@ -335,7 +335,7 @@ abstract class Geometry implements Serializable {
|
||||
|
||||
/**
|
||||
* backwards compatibility method
|
||||
*
|
||||
*
|
||||
* @return ...
|
||||
*/
|
||||
String getValue() {
|
||||
@@ -354,7 +354,7 @@ abstract class Geometry implements Serializable {
|
||||
* NULL or inconsistent subgeometries. BinaryParser and WKTParser should
|
||||
* only generate consistent geometries.
|
||||
* BinaryWriter may produce invalid results on inconsistent geometries.
|
||||
*
|
||||
*
|
||||
* @return true if all checks are passed.
|
||||
*/
|
||||
boolean checkConsistency() {
|
||||
@@ -363,7 +363,7 @@ abstract class Geometry implements Serializable {
|
||||
|
||||
/**
|
||||
* Splits the SRID=4711; part of a EWKT rep if present and sets the srid.
|
||||
*
|
||||
*
|
||||
* @param value
|
||||
* ...
|
||||
* @return value without the SRID=4711; part
|
||||
@@ -374,7 +374,7 @@ abstract class Geometry implements Serializable {
|
||||
int index = v.indexOf(';', 5); // sridprefix length is 5
|
||||
if (index == -1) {
|
||||
throw new IllegalArgumentException(
|
||||
"Error parsing Geometry - SRID not delimited with ';' ");
|
||||
"Error parsing Geometry - SRID not delimited with ';' ");
|
||||
}
|
||||
this.srid = Integer.parseInt(v.substring(5, index));
|
||||
return v.substring(index + 1).trim();
|
||||
|
||||
@@ -37,7 +37,7 @@ abstract class ValueGetter {
|
||||
|
||||
/**
|
||||
* Get a byte, should be equal for all endians
|
||||
*
|
||||
*
|
||||
* @return ...
|
||||
*/
|
||||
byte getByte() {
|
||||
@@ -58,7 +58,7 @@ abstract class ValueGetter {
|
||||
|
||||
/**
|
||||
* Get a 32-Bit integer
|
||||
*
|
||||
*
|
||||
* @param index
|
||||
* ...
|
||||
* @return ...
|
||||
@@ -68,7 +68,7 @@ abstract class ValueGetter {
|
||||
/**
|
||||
* Get a long value. This is not needed directly, but as a nice side-effect
|
||||
* from GetDouble.
|
||||
*
|
||||
*
|
||||
* @param index
|
||||
* ...
|
||||
* @return ...
|
||||
@@ -77,7 +77,7 @@ abstract class ValueGetter {
|
||||
|
||||
/**
|
||||
* Get a double.
|
||||
*
|
||||
*
|
||||
* @return ...
|
||||
*/
|
||||
double getDouble() {
|
||||
@@ -95,19 +95,19 @@ abstract class ValueGetter {
|
||||
@Override
|
||||
protected int getInt(int index) {
|
||||
return ((data[index] & 0xFF) << 24) + ((data[index + 1] & 0xFF) << 16)
|
||||
+ ((data[index + 2] & 0xFF) << 8) + (data[index + 3] & 0xFF);
|
||||
+ ((data[index + 2] & 0xFF) << 8) + (data[index + 3] & 0xFF);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected long getLong(int index) {
|
||||
|
||||
return ((long) (data[index] & 0xFF) << 56) | ((long) (data[index + 1] & 0xFF) << 48)
|
||||
| ((long) (data[index + 2] & 0xFF) << 40)
|
||||
| ((long) (data[index + 3] & 0xFF) << 32)
|
||||
| ((long) (data[index + 4] & 0xFF) << 24)
|
||||
| ((long) (data[index + 5] & 0xFF) << 16)
|
||||
| ((long) (data[index + 6] & 0xFF) << 8)
|
||||
| ((long) (data[index + 7] & 0xFF) << 0);
|
||||
| ((long) (data[index + 2] & 0xFF) << 40)
|
||||
| ((long) (data[index + 3] & 0xFF) << 32)
|
||||
| ((long) (data[index + 4] & 0xFF) << 24)
|
||||
| ((long) (data[index + 5] & 0xFF) << 16)
|
||||
| ((long) (data[index + 6] & 0xFF) << 8)
|
||||
| ((long) (data[index + 7] & 0xFF) << 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,18 +121,18 @@ abstract class ValueGetter {
|
||||
@Override
|
||||
protected int getInt(int index) {
|
||||
return ((data[index + 3] & 0xFF) << 24) + ((data[index + 2] & 0xFF) << 16)
|
||||
+ ((data[index + 1] & 0xFF) << 8) + (data[index] & 0xFF);
|
||||
+ ((data[index + 1] & 0xFF) << 8) + (data[index] & 0xFF);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected long getLong(int index) {
|
||||
return ((long) (data[index + 7] & 0xFF) << 56)
|
||||
| ((long) (data[index + 6] & 0xFF) << 48)
|
||||
| ((long) (data[index + 5] & 0xFF) << 40)
|
||||
| ((long) (data[index + 4] & 0xFF) << 32)
|
||||
| ((long) (data[index + 3] & 0xFF) << 24)
|
||||
| ((long) (data[index + 2] & 0xFF) << 16)
|
||||
| ((long) (data[index + 1] & 0xFF) << 8) | ((long) (data[index] & 0xFF) << 0);
|
||||
| ((long) (data[index + 6] & 0xFF) << 48)
|
||||
| ((long) (data[index + 5] & 0xFF) << 40)
|
||||
| ((long) (data[index + 4] & 0xFF) << 32)
|
||||
| ((long) (data[index + 3] & 0xFF) << 24)
|
||||
| ((long) (data[index + 2] & 0xFF) << 16)
|
||||
| ((long) (data[index + 1] & 0xFF) << 8) | ((long) (data[index] & 0xFF) << 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,35 +73,35 @@ public class WKBReader {
|
||||
data.getInt();
|
||||
}
|
||||
switch (realtype) {
|
||||
case Geometry.POINT:
|
||||
mGeom.startPoints();
|
||||
parsePoint(data, haveZ, haveM);
|
||||
break;
|
||||
case Geometry.LINESTRING:
|
||||
mGeom.startLine();
|
||||
parseLineString(data, haveZ, haveM);
|
||||
break;
|
||||
case Geometry.POLYGON:
|
||||
mGeom.startPolygon();
|
||||
parsePolygon(data, haveZ, haveM);
|
||||
break;
|
||||
case Geometry.MULTIPOINT:
|
||||
mGeom.startPoints();
|
||||
parseMultiPoint(data);
|
||||
break;
|
||||
case Geometry.MULTILINESTRING:
|
||||
mGeom.startLine();
|
||||
parseMultiLineString(data);
|
||||
break;
|
||||
case Geometry.MULTIPOLYGON:
|
||||
mGeom.startPolygon();
|
||||
parseMultiPolygon(data);
|
||||
break;
|
||||
case Geometry.GEOMETRYCOLLECTION:
|
||||
parseCollection(data);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown Geometry Type: " + realtype);
|
||||
case Geometry.POINT:
|
||||
mGeom.startPoints();
|
||||
parsePoint(data, haveZ, haveM);
|
||||
break;
|
||||
case Geometry.LINESTRING:
|
||||
mGeom.startLine();
|
||||
parseLineString(data, haveZ, haveM);
|
||||
break;
|
||||
case Geometry.POLYGON:
|
||||
mGeom.startPolygon();
|
||||
parsePolygon(data, haveZ, haveM);
|
||||
break;
|
||||
case Geometry.MULTIPOINT:
|
||||
mGeom.startPoints();
|
||||
parseMultiPoint(data);
|
||||
break;
|
||||
case Geometry.MULTILINESTRING:
|
||||
mGeom.startLine();
|
||||
parseMultiLineString(data);
|
||||
break;
|
||||
case Geometry.MULTIPOLYGON:
|
||||
mGeom.startPolygon();
|
||||
parseMultiPolygon(data);
|
||||
break;
|
||||
case Geometry.GEOMETRYCOLLECTION:
|
||||
parseCollection(data);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown Geometry Type: " + realtype);
|
||||
}
|
||||
|
||||
if (count == 0) {
|
||||
@@ -132,7 +132,7 @@ public class WKBReader {
|
||||
|
||||
/**
|
||||
* Parse an Array of "full" Geometries
|
||||
*
|
||||
*
|
||||
* @param data
|
||||
* ...
|
||||
* @param count
|
||||
@@ -193,7 +193,6 @@ public class WKBReader {
|
||||
if (i > 0)
|
||||
mGeom.startHole();
|
||||
|
||||
|
||||
int points = data.getInt();
|
||||
|
||||
for (int j = 0; j < points; j++) {
|
||||
@@ -254,7 +253,7 @@ public class WKBReader {
|
||||
|
||||
/**
|
||||
* Converting a string of hex character to bytes
|
||||
*
|
||||
*
|
||||
* from http://stackoverflow.com/questions/140131/convert-a-string-
|
||||
* representation-of-a-hex-dump-to-a-byte-array-using-java
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user