use of com.vividsolutions.jts.geom.Coordinate in project ili2db by claeis.
the class Iox2fgdb method multisurface2wkb.
public byte[] multisurface2wkb(// SurfaceOrAreaType type)
IomObject multisurfaceObj, // SurfaceOrAreaType type)
boolean asCurvePolygon, // SurfaceOrAreaType type)
double strokeP, // SurfaceOrAreaType type)
int srsId) throws IoxException {
if (multisurfaceObj == null) {
return null;
}
byte[] ret = null;
os.reset();
if (asCurvePolygon) {
int shapeType = EsriShpConstants.ShapeGeneralPolygon;
shapeType |= EsriShpConstants.shapeHasCurves;
shapeType |= (outputDimension == 3 ? EsriShpConstants.shapeHasZs : 0);
os.writeInt(shapeType);
} else {
if (outputDimension == 3) {
os.writeInt(EsriShpConstants.ShapePolygonZ);
} else {
os.writeInt(EsriShpConstants.ShapePolygon);
}
}
java.util.ArrayList<Polygon> polygons = new java.util.ArrayList<Polygon>();
// boundingBox
Envelope env = new Envelope();
int surfacec = multisurfaceObj.getattrvaluecount("surface");
for (int surfacei = 0; surfacei < surfacec; surfacei++) {
IomObject surface = multisurfaceObj.getattrobj("surface", surfacei);
IomObject iomSurfaceClone = new ch.interlis.iom_j.Iom_jObject("MULTISURFACE", null);
iomSurfaceClone.addattrobj("surface", surface);
Polygon polygon = Iox2jtsext.surface2JTS(iomSurfaceClone, strokeP);
polygons.add(polygon);
env.expandToInclude(polygon.getEnvelopeInternal());
}
os.writeDouble(env.getMinX());
os.writeDouble(env.getMinY());
os.writeDouble(env.getMaxX());
os.writeDouble(env.getMaxY());
// cParts The number of rings in the multisurface.
// cPoints The total number of points for all parts.
int cPart = 0;
int cPoints = 0;
for (Polygon polygon : polygons) {
cPart += 1;
cPoints += getNumPoints(polygon.getExteriorRing());
int holec = polygon.getNumInteriorRing();
cPart += holec;
for (int holei = 0; holei < holec; holei++) {
cPoints += getNumPoints(polygon.getInteriorRingN(holei));
}
}
os.writeInt(cPart);
os.writeInt(cPoints);
// parts[cParts] An array of length NumParts. Stores, for each Ring, the index of its
// first point in the points array. Array indexes are with respect to 0.
int partStart = 0;
for (Polygon polygon : polygons) {
os.writeInt(partStart);
partStart += getNumPoints(polygon.getExteriorRing());
int holec = polygon.getNumInteriorRing();
for (int holei = 0; holei < holec; holei++) {
os.writeInt(partStart);
partStart += getNumPoints(polygon.getInteriorRingN(holei));
}
}
java.util.ArrayList<Arc> arcs = null;
if (asCurvePolygon) {
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 = polygons.get(0).getExteriorRing().getStartPoint().getCoordinate();
if (outputDimension == 3) {
zMin[0] = coord.z;
zMax[0] = coord.z;
}
}
int startPtIdx = 0;
for (Polygon polygon : polygons) {
// shell is always in clockwise order
// holes are in a counterclockwise direction
LineString polyline = polygon.getExteriorRing();
polyline = asOneLine(polyline);
if (CGAlgorithms.isCCW(polyline.getCoordinates())) {
polyline = (LineString) polyline.reverse();
}
writePoints(polyline, false, zv, zMin, zMax, startPtIdx, arcs);
startPtIdx += getNumPoints(polyline);
int holec = polygon.getNumInteriorRing();
for (int holei = 0; holei < holec; holei++) {
polyline = polygon.getInteriorRingN(holei);
polyline = asOneLine(polyline);
if (!CGAlgorithms.isCCW(polyline.getCoordinates())) {
polyline = (LineString) polyline.reverse();
}
writePoints(polyline, true, zv, zMin, zMax, startPtIdx, arcs);
startPtIdx += getNumPoints(polyline);
}
}
if (outputDimension == 3) {
// zMin
os.writeDouble(zMin[0]);
// zMax
os.writeDouble(zMax[0]);
// Zs[cPoints]
for (Double z : zv) {
os.writeDouble(z);
}
}
if (asCurvePolygon) {
writeArcs(arcs);
}
ret = os.toByteArray();
return ret;
}
use of com.vividsolutions.jts.geom.Coordinate in project openems by OpenEMS.
the class SymmetricPowerProxy method writePower.
@Override
protected void writePower() {
super.writePower();
if (dynamicLimitations.size() > 0) {
Point p = reduceToZero();
Coordinate c = p.getCoordinate();
try {
setGeometry(p);
} catch (PowerException e) {
}
double activePowerDelta = c.x - lastActivePower;
double reactivePowerDelta = c.y - lastReactivePower;
lastActivePower += activePowerDelta / 2;
lastReactivePower += reactivePowerDelta / 2;
this.activePower = Optional.of((long) lastActivePower);
this.reactivePower = Optional.of((long) lastReactivePower);
}
}
use of com.vividsolutions.jts.geom.Coordinate in project openems by OpenEMS.
the class Test method getUnionAround.
private static Geometry getUnionAround(Geometry g1, Geometry g2) {
GeometryFactory factory = new GeometryFactory();
Geometry g1dens = Densifier.densify(g1, 10000);
Geometry g2dens = Densifier.densify(g2, 10000);
List<Geometry> geometries = new ArrayList<>();
geometries.add(g1);
for (Coordinate c : g1dens.getCoordinates()) {
geometries.add(AffineTransformation.translationInstance(c.x, c.y).transform(g2));
}
geometries.add(g2);
for (Coordinate c : g2dens.getCoordinates()) {
geometries.add(AffineTransformation.translationInstance(c.x, c.y).transform(g1));
}
GeometryCollection collection = new GeometryCollection(geometries.toArray(new Geometry[geometries.size()]), factory);
return collection.union();
}
use of com.vividsolutions.jts.geom.Coordinate in project openems by OpenEMS.
the class SMaxLimitation method setSMax.
public void setSMax(Long sMax, Long xNull, Long yNull) {
if (sMax != this.sMax) {
if (sMax != null) {
shapeFactory.setCentre(new Coordinate(xNull, yNull));
shapeFactory.setSize(sMax * 2);
shapeFactory.setNumPoints(32);
this.circle = shapeFactory.createCircle();
} else {
this.circle = null;
}
this.sMax = sMax;
notifyListeners();
}
}
use of com.vividsolutions.jts.geom.Coordinate in project openems by OpenEMS.
the class SymmetricPower method getClosestP.
/**
* Calculates the colses activepower point according to the parameter p
*
* @param p
* @return
*/
private Long getClosestP(long p) {
Coordinate[] coordinates = new Coordinate[] { new Coordinate(p, maxApparentPower), new Coordinate(p, maxApparentPower * -1) };
LineString line = FACTORY.createLineString(coordinates);
DistanceOp distance = new DistanceOp(geometry, line);
GeometryLocation[] locations = distance.nearestLocations();
for (GeometryLocation location : locations) {
if (!location.getGeometryComponent().equals(line)) {
return (long) location.getCoordinate().x;
}
}
return null;
}
Aggregations