public class VectorObject extends java.lang.Object implements java.lang.Iterable<VectorObject>
You can create these yourself, but they are typically read from data files, such as GeoJSON or Shapefiles.
The VectorObject is meant to be somewhat opaque (but not as opaque as originally planned). If you need to do a lot of manipulation of your vector data, it's best ot do it elsewhere and then convert to a VectorObject.
Modifier and Type | Class and Description |
---|---|
static class |
VectorObject.MaplyVectorObjectType |
Constructor and Description |
---|
VectorObject()
Construct empty.
|
Modifier and Type | Method and Description |
---|---|
void |
addAreal(Point2d[] pts)
Add an areal feature with one external loop.
|
void |
addAreal(Point2d[] ext,
Point2d[][] holes)
Add an areal feature with a single exterior loop and one or more interior loops.
|
void |
addLinear(Point2d[] pts)
Add a linear feature
|
void |
addPoint(Point2d pt)
Add a single point
|
VectorObject |
arealsToLinears()
Convert any areal features to linears (just the outline) and return
a new vector object or null.
|
double |
areaOfOuterLoops()
Area of all the out loops together.
|
boolean |
boundingBox(Point2d ll,
Point2d ur)
Bounding box of all the various features together
|
Point2d |
center()
Calculate the center (not the centroid).
|
Point2d |
centroid()
Calculate the centroid of the object.
|
VectorObject |
clipToGrid(Point2d size)
Clip the given areal features to a grid of the given size.
|
VectorObject |
clipToMbr(Mbr mbr)
Clip the given features to an Mbr
|
int |
countPoints()
Returns the total number of points in a feature.
|
VectorObject |
deepCopy()
Make a complete copy of the vector object and return it.
|
protected void |
deepCopyNative(VectorObject vecObj) |
VectorObject |
filterClippedEdges()
Filter out edges created from clipping areal features on the server.
|
void |
finalize() |
boolean |
fromGeoJSON(java.lang.String json)
Load vector objects from a GeoJSON string.
|
static java.util.Map<java.lang.String,VectorObject> |
FromGeoJSONAssembly(java.lang.String json)
Load vector objects from a GeoJSON assembly, which is just a bunch of GeoJSON stuck together.
|
boolean |
fromShapeFile(java.lang.String fileName)
Load vector objects from a Shapefile.
|
AttrDictionary |
getAttributes()
Return attributes for the feature.
|
boolean |
getSelectable()
On if this features is selectable.
|
VectorObject.MaplyVectorObjectType |
getVectorType()
The vector type is one of point, linear, linear3d, areal, or a combination.
|
VectorIterator |
iterator()
Vector objects can be made of lots of smaller objects.
|
Point2d |
largestLoopCenter(Point2d ll,
Point2d ur)
Find the largest loop and return its center.
|
double |
linearMiddle(Point2d middle)
Calculate the midpoint of a multi-point line.
|
double |
linearMiddle(Point2d middle,
CoordSystem coordSys)
Calculate the midpoint of a multi-point line.
|
VectorObject |
linearsToAreals()
Convert any linears features into areals, by closing them and return
a new vector object or null.
|
void |
mergeVectorsFrom(VectorObject other)
Merge the vectors from the other vector object into this one.
|
boolean |
middleCoordinate(Point2d middle)
Return the point right in the middle (index-wise) of a linear features.
|
boolean |
pointInside(Point2d pt)
Return true if the given point (in geo radians) is inside the vector feature.
|
VectorObject |
reproject(CoordSystem srcSystem,
double scale,
CoordSystem destSystem)
Reproject the vectors from the given system (geographic, by default) into
the destination coordinate system.
|
void |
setAttributes(AttrDictionary attrs)
Reset the attributes for the feature.
|
void |
setSelectable(boolean newSelect)
Turn this on if you want the vector object to be selectable.
|
VectorObject |
subdivideToFlatGreatCircle(double epsilon)
Subdivide the edges in this feature to a given tolerance, using great circle math.
|
VectorObject |
subdivideToGlobe(double epsilon)
Subdivide the edges in this feature to a given tolerance.
|
VectorObject |
subdivideToGlobeGreatCircle(double epsilon)
Subdivide the edges in this feature to a given tolerance, using great circle math.
|
VectorObject |
tesselate()
Tesselate the areal features and return a new vector object.
|
public VectorObject.MaplyVectorObjectType getVectorType()
public void setSelectable(boolean newSelect)
public boolean getSelectable()
public AttrDictionary getAttributes()
public void setAttributes(AttrDictionary attrs)
public void addPoint(Point2d pt)
public void addLinear(Point2d[] pts)
public void addAreal(Point2d[] pts)
public void addAreal(Point2d[] ext, Point2d[][] holes)
public void mergeVectorsFrom(VectorObject other)
public VectorIterator iterator()
iterator
in interface java.lang.Iterable<VectorObject>
public Point2d center()
public Point2d centroid()
public Point2d largestLoopCenter(Point2d ll, Point2d ur)
ll
- Lower left corner of the largest loop.ur
- Upper right corner of the largest loop.public double linearMiddle(Point2d middle)
middle
- Midpoint of the linepublic double linearMiddle(Point2d middle, CoordSystem coordSys)
middle
- Midpoint of the linecoordSys
- Coordinate system to project into first.public boolean middleCoordinate(Point2d middle)
middle
- Return pointpublic boolean pointInside(Point2d pt)
public double areaOfOuterLoops()
public int countPoints()
public boolean boundingBox(Point2d ll, Point2d ur)
public VectorObject subdivideToGlobe(double epsilon)
public VectorObject subdivideToGlobeGreatCircle(double epsilon)
public VectorObject subdivideToFlatGreatCircle(double epsilon)
public VectorObject tesselate()
public VectorObject clipToGrid(Point2d size)
public VectorObject clipToMbr(Mbr mbr)
public VectorObject reproject(CoordSystem srcSystem, double scale, CoordSystem destSystem)
srcSystem
- Source coordinate system (that the data is already in)scale
- Scale factor to apply to the coordinates. 1.0 is a good default.destSystem
- Destination coordinate system that we'll project data into.public VectorObject filterClippedEdges()
public VectorObject linearsToAreals()
public VectorObject arealsToLinears()
public boolean fromGeoJSON(java.lang.String json)
json
- The GeoSJON string, presumably read from a file or over the networkpublic boolean fromShapeFile(java.lang.String fileName)
fileName
- The filename of the Shapefile.public VectorObject deepCopy()
protected void deepCopyNative(VectorObject vecObj)
public static java.util.Map<java.lang.String,VectorObject> FromGeoJSONAssembly(java.lang.String json)
json
- public void finalize()
finalize
in class java.lang.Object