public class PointSet extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
int |
capacity |
String |
description
A detailed textual description of this PointSet
|
protected GraphService |
graphService |
String |
id
A server-unique identifier for this PointSet
|
protected String[] |
ids
A unique identifier for each feature.
|
String |
label
A short description of this PointSet for use in a legend or menu
|
protected double[] |
lats
The latitude of each feature (or its centroid if it's not a point).
|
protected double[] |
lons
The longitude of each feature (or its centroid if it's not a point).
|
protected com.vividsolutions.jts.geom.Polygon[] |
polygons
The polygon for each feature (which is reduced to a centroid point for routing purposes).
|
Map<String,int[]> |
properties |
Map<String,PropertyMetadata> |
propMetadata |
int[][] |
times
Deprecated.
|
Constructor and Description |
---|
PointSet(int capacity)
Create a PointSet manually by defining capacity and calling
addFeature(geom, data) repeatedly.
|
Modifier and Type | Method and Description |
---|---|
void |
addFeature(PointFeature feat,
int index)
Add a single feature with a variable number of free-form properties.
|
int |
featureCount() |
static PointSet |
fromCsv(File filename)
Rather than trying to load anything any everything, we stick to a strict
format and rely on other tools to get the data into the correct format.
|
static PointSet |
fromGeoJson(File filename) |
static PointSet |
fromShapefile(File file) |
static PointSet |
fromShapefile(File file,
String originIDField,
List<String> propertyFields) |
com.vividsolutions.jts.geom.Coordinate |
getCoordinate(int index)
Returns a new coordinate object for the feature at the given index in this set, or its centroid.
|
PointFeature |
getFeature(int index) |
int |
getIndexForFeature(String featureId)
Get the index of a particular feature ID in this pointset.
|
double |
getLat(int i)
Using getter methods here to allow generating coordinates and geometries on demand instead of storing them.
|
double |
getLon(int i) |
PropertyMetadata |
getOrCreatePropertyForId(String id)
Gets the Category object for the given ID, creating it if it doesn't
exist.
|
SampleSet |
getOrCreateSampleSet(Graph graph) |
SampleSet |
getSampleSet(Graph g)
gets a sample set for a graph object -- does not require graph service to be set
|
SampleSet |
getSampleSet(String routerId)
gets a sample set for a given graph id -- requires graphservice to be set
|
LinkedPointSet |
link(StreetLayer streetLayer)
Creates an object similar to a SampleSet but for the new TransitNetwork representation.
|
static PointSet |
regularGrid(com.vividsolutions.jts.geom.Envelope envelope,
double gridSizeMeters) |
void |
setGraphService(GraphService graphService)
Adds a graph service to allow for auto creation of SampleSets for a given
graph
|
void |
setLabel(String catId,
String label) |
void |
setStyle(String catId,
String styleAttribute,
String styleValue) |
PointSet |
slice(int start,
int end) |
PointSet |
slice(List<String> ids)
Get a subset of this point set containing only the specified point IDs.
|
static int |
validateGeoJson(InputStream is)
Examines a JSON stream to see if it matches the expected OTPA format.
|
void |
writeJson(OutputStream out) |
void |
writeJson(OutputStream out,
Boolean forcePoints)
Use the Jackson streaming API to output this as GeoJSON without creating
another object.
|
void |
writeJsonProperties(com.fasterxml.jackson.core.JsonGenerator jgen) |
protected void |
writeStructured(int i,
com.fasterxml.jackson.core.JsonGenerator jgen)
This will be called once per point in an origin/destination pointset, and
once per origin in a one- or many-to-many indicator.
|
protected void |
writeTimes(com.fasterxml.jackson.core.JsonGenerator jgen,
int[] times)
Pairs an array of times with the array of features in this pointset,
writing out the resulting (ID,time) pairs to a JSON object.
|
public String id
public String label
public String description
public Map<String,PropertyMetadata> propMetadata
public int capacity
protected GraphService graphService
@Deprecated public int[][] times
protected String[] ids
protected double[] lats
protected double[] lons
protected com.vividsolutions.jts.geom.Polygon[] polygons
public PointSet(int capacity)
capacity
- expected number of features to be added to this PointSet.public static PointSet fromCsv(File filename) throws IOException
IOException
public static PointSet fromShapefile(File file) throws org.opengis.referencing.NoSuchAuthorityCodeException, IOException, org.opengis.referencing.FactoryException, EmptyPolygonException, UnsupportedGeometryException
org.opengis.referencing.NoSuchAuthorityCodeException
IOException
org.opengis.referencing.FactoryException
EmptyPolygonException
UnsupportedGeometryException
public static PointSet fromShapefile(File file, String originIDField, List<String> propertyFields) throws IOException, org.opengis.referencing.NoSuchAuthorityCodeException, org.opengis.referencing.FactoryException, EmptyPolygonException, UnsupportedGeometryException
IOException
org.opengis.referencing.NoSuchAuthorityCodeException
org.opengis.referencing.FactoryException
EmptyPolygonException
UnsupportedGeometryException
public static int validateGeoJson(InputStream is)
public void setGraphService(GraphService graphService)
public SampleSet getSampleSet(String routerId)
public SampleSet getSampleSet(Graph g)
g
- a graph objectspublic int featureCount()
public void addFeature(PointFeature feat, int index)
feat
- must be a Point, a Polygon, or a single-element MultiPolygonpublic PointFeature getFeature(int index)
public PropertyMetadata getOrCreatePropertyForId(String id)
public void writeJson(OutputStream out)
public void writeJson(OutputStream out, Boolean forcePoints)
public void writeJsonProperties(com.fasterxml.jackson.core.JsonGenerator jgen) throws com.fasterxml.jackson.core.JsonGenerationException, IOException
com.fasterxml.jackson.core.JsonGenerationException
IOException
protected void writeTimes(com.fasterxml.jackson.core.JsonGenerator jgen, int[] times) throws IOException
IOException
protected void writeStructured(int i, com.fasterxml.jackson.core.JsonGenerator jgen) throws IOException
IOException
public PointSet slice(List<String> ids)
public PointSet slice(int start, int end)
public int getIndexForFeature(String featureId)
public static PointSet regularGrid(com.vividsolutions.jts.geom.Envelope envelope, double gridSizeMeters)
public com.vividsolutions.jts.geom.Coordinate getCoordinate(int index)
public LinkedPointSet link(StreetLayer streetLayer)
public double getLat(int i)
public double getLon(int i)
Copyright © 2015. All rights reserved.