use of com.vividsolutions.jts.operation.distance.GeometryLocation 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;
}
use of com.vividsolutions.jts.operation.distance.GeometryLocation in project openems by OpenEMS.
the class SymmetricPower method reduceToZero.
protected Point reduceToZero() {
if (getGeometry() instanceof Point) {
return (Point) getGeometry();
}
Point pZero = FACTORY.createPoint(ZERO);
DistanceOp distance = new DistanceOp(getGeometry(), pZero);
GeometryLocation[] locations = distance.nearestLocations();
Point result = pZero;
for (GeometryLocation location : locations) {
Geometry g = location.getGeometryComponent();
if (!g.equals(pZero)) {
result = FACTORY.createPoint(location.getCoordinate());
break;
}
}
return result;
}
use of com.vividsolutions.jts.operation.distance.GeometryLocation in project openems by OpenEMS.
the class SymmetricPower method getClosestQ.
/**
* Calculates the colses reactivepower point according to the parameter q
*
* @param p
* @return
*/
private Long getClosestQ(long q) {
Coordinate[] coordinates = new Coordinate[] { new Coordinate(maxApparentPower, q), new Coordinate(maxApparentPower * -1, q) };
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().y;
}
}
return null;
}
use of com.vividsolutions.jts.operation.distance.GeometryLocation in project openems by OpenEMS.
the class CosPhiLineCharacteristicLimitation method applyLimit.
@Override
protected Geometry applyLimit(Geometry geometry) throws PowerException {
if (line != null) {
Geometry newGeometry = geometry.intersection(line);
if (newGeometry.isEmpty()) {
DistanceOp distance = new DistanceOp(geometry, line);
GeometryLocation[] locations = distance.nearestLocations();
for (GeometryLocation location : locations) {
if (!location.getGeometryComponent().equals(line)) {
return factory.createPoint(location.getCoordinate());
}
}
} else {
return newGeometry;
}
}
return geometry;
}
use of com.vividsolutions.jts.operation.distance.GeometryLocation in project openems by OpenEMS.
the class PEqualLimitation method applyLimit.
@Override
protected Geometry applyLimit(Geometry geometry) throws PowerException {
if (line != null) {
Geometry newGeometry = geometry.intersection(line);
long maxApparentPower = power.getMaxApparentPower();
if (newGeometry.isEmpty()) {
Geometry smallerP = SymmetricPower.intersectRect(geometry, 0, p, maxApparentPower * -1, maxApparentPower);
if (!smallerP.isEmpty()) {
DistanceOp distance = new DistanceOp(smallerP, line);
GeometryLocation[] locations = distance.nearestLocations();
long maxP = 0;
for (GeometryLocation location : locations) {
if (!location.getGeometryComponent().equals(line)) {
maxP = (long) location.getCoordinate().x;
break;
}
}
Coordinate[] coordinates = new Coordinate[] { new Coordinate(maxP, maxApparentPower), new Coordinate(maxP, maxApparentPower * -1) };
line = factory.createLineString(coordinates);
return geometry.intersection(line);
} else {
DistanceOp distance = new DistanceOp(geometry, line);
GeometryLocation[] locations = distance.nearestLocations();
for (GeometryLocation location : locations) {
if (!location.getGeometryComponent().equals(line)) {
Coordinate[] coordinates = new Coordinate[] { new Coordinate(location.getCoordinate().x, maxApparentPower), new Coordinate(location.getCoordinate().x, maxApparentPower * -1) };
line = factory.createLineString(coordinates);
return geometry.intersection(line);
}
}
}
} else {
return newGeometry;
}
}
return geometry;
}
Aggregations