@Test public void testGetCenterPosition() throws GeoRegionException { OdePosition3D result = region2.getCenterPosition(); assertEquals(BigDecimal.valueOf(33.33), result.getLatitude()); assertEquals(BigDecimal.valueOf(-44.44), result.getLongitude()); }
public OdePosition3D getCenterPosition() { Point2D nw = new Point2D.Double( nwCorner.getLongitude().doubleValue(), nwCorner.getLatitude().doubleValue()); Point2D se = new Point2D.Double( seCorner.getLongitude().doubleValue(), seCorner.getLatitude().doubleValue()); Point2D midPoint = new Point2D.Double( nw.getX() + (se.getX() - nw.getX()) / 2, se.getY() + (nw.getY() - se.getY()) / 2); if (nwCorner.getElevation() != null && seCorner.getElevation() != null) { double minElev = Math.min(nwCorner.getElevation().doubleValue(), seCorner.getElevation().doubleValue()); double diffElev = Math.abs(nwCorner.getElevation().doubleValue() - seCorner.getElevation().doubleValue()); return new OdePosition3D( BigDecimal.valueOf(midPoint.getY()), BigDecimal.valueOf(midPoint.getX()), BigDecimal.valueOf(minElev + diffElev/2)); } else { return new OdePosition3D( BigDecimal.valueOf(midPoint.getY()), BigDecimal.valueOf(midPoint.getX()), null); } }
OdeGeoRegion extends OdeObject { public OdePosition3D getCenterPosition() { Point2D nw = new Point2D.Double( nwCorner.getLongitude().doubleValue(), nwCorner.getLatitude().doubleValue()); Point2D se = new Point2D.Double( seCorner.getLongitude().doubleValue(), seCorner.getLatitude().doubleValue()); Point2D midPoint = new Point2D.Double( nw.getX() + (se.getX() - nw.getX()) / 2, se.getY() + (nw.getY() - se.getY()) / 2); if (nwCorner.getElevation() != null && seCorner.getElevation() != null) { double minElev = Math.min(nwCorner.getElevation().doubleValue(), seCorner.getElevation().doubleValue()); double diffElev = Math.abs(nwCorner.getElevation().doubleValue() - seCorner.getElevation().doubleValue()); return new OdePosition3D( BigDecimal.valueOf(midPoint.getY()), BigDecimal.valueOf(midPoint.getX()), BigDecimal.valueOf(minElev + diffElev/2)); } else { return new OdePosition3D( BigDecimal.valueOf(midPoint.getY()), BigDecimal.valueOf(midPoint.getX()), null); } } }
OdeGeoRegion extends OdeObject { public OdePosition3D getCenterPosition() { Point2D nw = new Point2D.Double( nwCorner.getLongitude().doubleValue(), nwCorner.getLatitude().doubleValue()); Point2D se = new Point2D.Double( seCorner.getLongitude().doubleValue(), seCorner.getLatitude().doubleValue()); Point2D midPoint = new Point2D.Double( nw.getX() + (se.getX() - nw.getX()) / 2, se.getY() + (nw.getY() - se.getY()) / 2); if (nwCorner.getElevation() != null && seCorner.getElevation() != null) { double minElev = Math.min(nwCorner.getElevation().doubleValue(), seCorner.getElevation().doubleValue()); double diffElev = Math.abs(nwCorner.getElevation().doubleValue() - seCorner.getElevation().doubleValue()); return new OdePosition3D( BigDecimal.valueOf(midPoint.getY()), BigDecimal.valueOf(midPoint.getX()), BigDecimal.valueOf(minElev + diffElev/2)); } else { return new OdePosition3D( BigDecimal.valueOf(midPoint.getY()), BigDecimal.valueOf(midPoint.getX()), null); } } OdeGeoRegion();  OdeGeoRegion(OdePosition3D nwCorner, OdePosition3D seCorner);  OdeGeoRegion(String serviceRegion); }
OdeGeoRegion extends OdeObject { public OdePosition3D getCenterPosition() { Point2D nw = new Point2D.Double( nwCorner.getLongitude().doubleValue(), nwCorner.getLatitude().doubleValue()); Point2D se = new Point2D.Double( seCorner.getLongitude().doubleValue(), seCorner.getLatitude().doubleValue()); Point2D midPoint = new Point2D.Double( nw.getX() + (se.getX() - nw.getX()) / 2, se.getY() + (nw.getY() - se.getY()) / 2); if (nwCorner.getElevation() != null && seCorner.getElevation() != null) { double minElev = Math.min(nwCorner.getElevation().doubleValue(), seCorner.getElevation().doubleValue()); double diffElev = Math.abs(nwCorner.getElevation().doubleValue() - seCorner.getElevation().doubleValue()); return new OdePosition3D( BigDecimal.valueOf(midPoint.getY()), BigDecimal.valueOf(midPoint.getX()), BigDecimal.valueOf(minElev + diffElev/2)); } else { return new OdePosition3D( BigDecimal.valueOf(midPoint.getY()), BigDecimal.valueOf(midPoint.getX()), null); } } OdeGeoRegion();  OdeGeoRegion(OdePosition3D nwCorner, OdePosition3D seCorner);  OdeGeoRegion(String serviceRegion); OdePosition3D getNwCorner(); OdeGeoRegion setNwCorner(OdePosition3D nwCorner); OdePosition3D getSeCorner(); OdeGeoRegion setSeCorner(OdePosition3D seCorner); OdePosition3D getCenterPosition(); @Override int hashCode(); @Override boolean equals(Object obj); boolean contains(OdePosition3D pos); boolean contains(OdeGeoRegion requestRegion); }
OdeGeoRegion extends OdeObject { public OdePosition3D getCenterPosition() { Point2D nw = new Point2D.Double( nwCorner.getLongitude().doubleValue(), nwCorner.getLatitude().doubleValue()); Point2D se = new Point2D.Double( seCorner.getLongitude().doubleValue(), seCorner.getLatitude().doubleValue()); Point2D midPoint = new Point2D.Double( nw.getX() + (se.getX() - nw.getX()) / 2, se.getY() + (nw.getY() - se.getY()) / 2); if (nwCorner.getElevation() != null && seCorner.getElevation() != null) { double minElev = Math.min(nwCorner.getElevation().doubleValue(), seCorner.getElevation().doubleValue()); double diffElev = Math.abs(nwCorner.getElevation().doubleValue() - seCorner.getElevation().doubleValue()); return new OdePosition3D( BigDecimal.valueOf(midPoint.getY()), BigDecimal.valueOf(midPoint.getX()), BigDecimal.valueOf(minElev + diffElev/2)); } else { return new OdePosition3D( BigDecimal.valueOf(midPoint.getY()), BigDecimal.valueOf(midPoint.getX()), null); } } OdeGeoRegion();  OdeGeoRegion(OdePosition3D nwCorner, OdePosition3D seCorner);  OdeGeoRegion(String serviceRegion); OdePosition3D getNwCorner(); OdeGeoRegion setNwCorner(OdePosition3D nwCorner); OdePosition3D getSeCorner(); OdeGeoRegion setSeCorner(OdePosition3D seCorner); OdePosition3D getCenterPosition(); @Override int hashCode(); @Override boolean equals(Object obj); boolean contains(OdePosition3D pos); boolean contains(OdeGeoRegion requestRegion);  }