use of com.vividsolutions.jts.geom.Envelope in project ili2db by claeis.
the class Iox2gpkg method multiline2wkb.
public byte[] multiline2wkb(IomObject obj, boolean asCompoundCurve, double p, int srsId) throws Iox2wkbException {
if (obj == null) {
return null;
}
try {
os.reset();
int polylinec = obj.getattrvaluecount(Wkb2iox.ATTR_POLYLINE);
Envelope env = new Envelope();
for (int polylinei = 0; polylinei < polylinec; polylinei++) {
IomObject polyline = obj.getattrobj(Wkb2iox.ATTR_POLYLINE, polylinei);
CompoundCurve curve = Iox2jtsext.polyline2JTS(polyline, false, p);
env.expandToInclude(curve.getEnvelopeInternal());
}
writeGeoPackageBinaryHeader(srsId, env);
Iox2wkb helper = new Iox2wkb(outputDimension, os.order());
for (int polylinei = 0; polylinei < polylinec; polylinei++) {
IomObject polyline = obj.getattrobj(Wkb2iox.ATTR_POLYLINE, polylinei);
os.write(helper.polyline2wkb(polyline, false, asCompoundCurve, p));
}
} catch (IOException e) {
throw new RuntimeException("Unexpected IO exception: " + e.getMessage());
} catch (IoxException e) {
throw new RuntimeException("Unexpected exception: " + e.getMessage());
}
return os.toByteArray();
}
use of com.vividsolutions.jts.geom.Envelope in project ili2db by claeis.
the class Iox2fgdb method multiline2wkb.
public byte[] multiline2wkb(IomObject obj, boolean asCompoundCurve, double p, int srsId) throws IoxException {
if (obj == null) {
return null;
}
os.reset();
int polylinec = obj.getattrvaluecount(Wkb2iox.ATTR_POLYLINE);
if (asCompoundCurve) {
int shapeType = EsriShpConstants.ShapeGeneralPolyline;
shapeType |= EsriShpConstants.shapeHasCurves;
shapeType |= (outputDimension == 3 ? EsriShpConstants.shapeHasZs : 0);
os.writeInt(shapeType);
} else {
if (outputDimension == 3) {
os.writeInt(EsriShpConstants.ShapePolylineZ);
} else {
os.writeInt(EsriShpConstants.ShapePolyline);
}
}
java.util.ArrayList<CompoundCurve> curves = new java.util.ArrayList<CompoundCurve>();
// boundingBox
Envelope env = new Envelope();
for (int polylinei = 0; polylinei < polylinec; polylinei++) {
IomObject polyline = obj.getattrobj(Wkb2iox.ATTR_POLYLINE, polylinei);
CompoundCurve curve = Iox2jtsext.polyline2JTS(polyline, false, p);
curves.add(curve);
env.expandToInclude(curve.getEnvelopeInternal());
}
os.writeDouble(env.getMinX());
os.writeDouble(env.getMinY());
os.writeDouble(env.getMaxX());
os.writeDouble(env.getMaxY());
// cParts The number of Lines in the Multiline.
// cPoints The total number of points for all lines.
int cPart = curves.size();
int cPoints = 0;
for (CompoundCurve curve : curves) {
cPoints += getNumPoints(curve);
}
os.writeInt(cPart);
os.writeInt(cPoints);
// parts[cParts] An array of length NumParts. Stores, for each Line, the index of its
// first point in the points array. Array indexes are with respect to 0.
int partStart = 0;
for (CompoundCurve curve : curves) {
os.writeInt(partStart);
partStart += getNumPoints(curve);
}
java.util.ArrayList<Arc> arcs = null;
if (asCompoundCurve) {
arcs = new java.util.ArrayList<Arc>();
}
java.util.ArrayList<Double> zv = null;
if (outputDimension == 3) {
zv = new java.util.ArrayList<Double>();
}
double[] zMin = new double[1];
double[] zMax = new double[1];
{
Coordinate coord = curves.get(0).getStartPoint().getCoordinate();
if (outputDimension == 3) {
zMin[0] = coord.z;
zMax[0] = coord.z;
}
}
int startPtIdx = 0;
for (CompoundCurve curve : curves) {
writePoints(curve, true, zv, zMin, zMax, startPtIdx, arcs);
startPtIdx += getNumPoints(curve);
}
if (outputDimension == 3) {
// zMin
os.writeDouble(zMin[0]);
// zMax
os.writeDouble(zMax[0]);
// Zs[cPoints]
for (Double z : zv) {
os.writeDouble(z);
}
}
if (asCompoundCurve) {
writeArcs(arcs);
}
return os.toByteArray();
}
use of com.vividsolutions.jts.geom.Envelope in project ili2db by claeis.
the class Iox2fgdb method polyline2wkb.
public byte[] polyline2wkb(IomObject polylineObj, boolean isSurfaceOrArea, boolean asCompoundCurve, double p, int srsId) throws IoxException {
if (polylineObj == null) {
return null;
}
byte[] ret = null;
CompoundCurve polyline = Iox2jtsext.polyline2JTS(polylineObj, false, p);
os.reset();
if (asCompoundCurve) {
int shapeType = EsriShpConstants.ShapeGeneralPolyline;
shapeType |= EsriShpConstants.shapeHasCurves;
shapeType |= (outputDimension == 3 ? EsriShpConstants.shapeHasZs : 0);
os.writeInt(shapeType);
} else {
if (outputDimension == 3) {
os.writeInt(EsriShpConstants.ShapePolylineZ);
} else {
os.writeInt(EsriShpConstants.ShapePolyline);
}
}
// boundingBox
Envelope env = polyline.getEnvelopeInternal();
os.writeDouble(env.getMinX());
os.writeDouble(env.getMinY());
os.writeDouble(env.getMaxX());
os.writeDouble(env.getMaxY());
// cParts The number of lines in the multiline.
// cPoints The total number of points for all parts.
int cPart = 1;
int cPoints = getNumPoints(polyline);
os.writeInt(cPart);
os.writeInt(cPoints);
int partStart = 0;
os.writeInt(partStart);
java.util.ArrayList<Arc> arcs = null;
if (asCompoundCurve) {
arcs = new java.util.ArrayList<Arc>();
}
java.util.ArrayList<Double> zv = null;
if (outputDimension == 3) {
zv = new java.util.ArrayList<Double>();
}
double[] zMin = new double[1];
double[] zMax = new double[1];
{
Coordinate coord = polyline.getStartPoint().getCoordinate();
if (outputDimension == 3) {
zMin[0] = coord.z;
zMax[0] = coord.z;
}
}
int startPtIdx = 0;
writePoints(polyline, false, zv, zMin, zMax, startPtIdx, arcs);
if (outputDimension == 3) {
// zMin
os.writeDouble(zMin[0]);
// zMax
os.writeDouble(zMax[0]);
// Zs[cPoints]
for (Double z : zv) {
os.writeDouble(z);
}
}
if (asCompoundCurve) {
writeArcs(arcs);
}
ret = os.toByteArray();
return ret;
}
use of com.vividsolutions.jts.geom.Envelope in project OpenTripPlanner by opentripplanner.
the class HashGridSpatialIndex method insert.
public final void insert(LineString geom, final Object item) {
Coordinate[] coord = geom.getCoordinates();
final TLongSet keys = new TLongHashSet(coord.length * 8);
for (int i = 0; i < coord.length - 1; i++) {
// TODO Cut the segment if longer than bin size
// to reduce the number of wrong bins
Envelope env = new Envelope(coord[i], coord[i + 1]);
visit(env, true, new BinVisitor<T>() {
@Override
public boolean visit(List<T> bin, long mapKey) {
keys.add(mapKey);
return false;
}
});
}
keys.forEach(new TLongProcedure() {
@SuppressWarnings("unchecked")
@Override
public boolean execute(long key) {
// Note: bins have been initialized in the previous visit
bins.get(key).add((T) item);
nEntries++;
return true;
}
});
nObjects++;
}
use of com.vividsolutions.jts.geom.Envelope in project OpenTripPlanner by opentripplanner.
the class NoDownloadIDException method getValidateElements.
private List<String> getValidateElements() {
Envelope extent = graph.getExtent();
List<String> elements = new ArrayList<String>();
double minY = floor(extent.getMinY(), _latYStep);
double maxY = ceil(extent.getMaxY(), _latYStep);
double minX = floor(extent.getMinX(), _lonXStep);
double maxX = ceil(extent.getMaxX(), _lonXStep);
for (double y = minY; y < maxY; y += _latYStep) {
for (double x = minX; x < maxX; x += _lonXStep) {
Envelope region = new Envelope(x, x + _lonXStep, y, y + _latYStep);
String xmlRequestString = "<REQUEST_SERVICE_INPUT>" + "<AOI_GEOMETRY>" + "<EXTENT>" + "<TOP>" + region.getMaxY() + "</TOP>" + "<BOTTOM>" + region.getMinY() + "</BOTTOM>" + "<LEFT>" + region.getMinX() + "</LEFT>" + "<RIGHT>" + region.getMaxX() + "</RIGHT>" + "</EXTENT>" + "<SPATIALREFERENCE_WKID/>" + "</AOI_GEOMETRY>" + "<LAYER_INFORMATION>" + " <LAYER_IDS>" + dataset + "</LAYER_IDS>" + "</LAYER_INFORMATION>" + "<CHUNK_SIZE>250" + "</CHUNK_SIZE>" + "<ORIGINATOR/>" + "</REQUEST_SERVICE_INPUT>";
elements.add(xmlRequestString);
}
}
return elements;
}
Aggregations