Skip to content

Commit

Permalink
Merge pull request #11 from ngageoint/develop
Browse files Browse the repository at this point in the history
1.0.5 updates
  • Loading branch information
bosborn authored Feb 13, 2018
2 parents 780ac2e + a57f9a0 commit c9c60bc
Show file tree
Hide file tree
Showing 18 changed files with 2,219 additions and 42 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ Adheres to [Semantic Versioning](http://semver.org/).

---

## 1.0.5 (TBD)
## [1.0.5](https://github.com/ngageoint/geopackage-wkb-java/releases/tag/1.0.5) (02-13-2018)

* TBD
* Additional Curve Polygon support
* Geometry utilities: pointInPolygon, pointOnPolygonEdge, closedPolygon, pointOnLine, and pointOnPath
* Shamos-Hoey simple polygon detection

## [1.0.4](https://github.com/ngageoint/geopackage-wkb-java/releases/tag/1.0.4) (11-20-2017)

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ writer.close();

### Installation ###

Pull from the [Maven Central Repository](http://search.maven.org/#artifactdetails|mil.nga|wkb|1.0.4|jar) (JAR, POM, Source, Javadoc)
Pull from the [Maven Central Repository](http://search.maven.org/#artifactdetails|mil.nga|wkb|1.0.5|jar) (JAR, POM, Source, Javadoc)

```xml

<dependency>
<groupId>mil.nga</groupId>
<artifactId>wkb</artifactId>
<version>1.0.4</version>
<version>1.0.5</version>
</dependency>

```
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h2 class="project-tagline">by the National Geospatial-Intelligence Agency</h2>
<a href="http://ngageoint.github.io/geopackage-wkb-java/docs/api/" class="btn">API</a>
<a href="https://github.com/ngageoint/geopackage-wkb-java/zipball/master" class="btn">.zip</a>
<a href="https://github.com/ngageoint/geopackage-wkb-java/tarball/master" class="btn">.tar.gz</a>
<a href="http://search.maven.org/#artifactdetails|mil.nga|wkb|1.0.4|jar" class="btn">The Central Repository</a>
<a href="http://search.maven.org/#artifactdetails|mil.nga|wkb|1.0.5|jar" class="btn">The Central Repository</a>
</section>

<section class="main-content">
Expand Down
101 changes: 72 additions & 29 deletions src/main/java/mil/nga/wkb/util/GeometryEnvelopeBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import mil.nga.wkb.geom.CircularString;
import mil.nga.wkb.geom.CompoundCurve;
import mil.nga.wkb.geom.Curve;
import mil.nga.wkb.geom.CurvePolygon;
import mil.nga.wkb.geom.Geometry;
import mil.nga.wkb.geom.GeometryCollection;
import mil.nga.wkb.geom.GeometryEnvelope;
Expand Down Expand Up @@ -52,45 +54,50 @@ public static GeometryEnvelope buildEnvelope(Geometry geometry) {
* @param geometry
* geometry to build envelope from
* @param envelope
* envelope to expand
* geometry envelope to expand
*/
public static void buildEnvelope(Geometry geometry,
GeometryEnvelope envelope) {

GeometryType geometryType = geometry.getGeometryType();
switch (geometryType) {
case POINT:
addPointMessage(envelope, (Point) geometry);
addPoint(envelope, (Point) geometry);
break;
case LINESTRING:
addLineStringMessage(envelope, (LineString) geometry);
addLineString(envelope, (LineString) geometry);
break;
case POLYGON:
addPolygonMessage(envelope, (Polygon) geometry);
addPolygon(envelope, (Polygon) geometry);
break;
case MULTIPOINT:
addMultiPointMessage(envelope, (MultiPoint) geometry);
addMultiPoint(envelope, (MultiPoint) geometry);
break;
case MULTILINESTRING:
addMultiLineStringMessage(envelope, (MultiLineString) geometry);
addMultiLineString(envelope, (MultiLineString) geometry);
break;
case MULTIPOLYGON:
addMultiPolygonMessage(envelope, (MultiPolygon) geometry);
addMultiPolygon(envelope, (MultiPolygon) geometry);
break;
case CIRCULARSTRING:
addLineStringMessage(envelope, (CircularString) geometry);
addLineString(envelope, (CircularString) geometry);
break;
case COMPOUNDCURVE:
addCompoundCurveMessage(envelope, (CompoundCurve) geometry);
addCompoundCurve(envelope, (CompoundCurve) geometry);
break;
case CURVEPOLYGON:
@SuppressWarnings("unchecked")
CurvePolygon<Curve> curvePolygon = (CurvePolygon<Curve>) geometry;
addCurvePolygon(envelope, curvePolygon);
break;
case POLYHEDRALSURFACE:
addPolyhedralSurfaceMessage(envelope, (PolyhedralSurface) geometry);
addPolyhedralSurface(envelope, (PolyhedralSurface) geometry);
break;
case TIN:
addPolyhedralSurfaceMessage(envelope, (TIN) geometry);
addPolyhedralSurface(envelope, (TIN) geometry);
break;
case TRIANGLE:
addPolygonMessage(envelope, (Triangle) geometry);
addPolygon(envelope, (Triangle) geometry);
break;
case GEOMETRYCOLLECTION:
updateHasZandM(envelope, geometry);
Expand All @@ -107,10 +114,12 @@ public static void buildEnvelope(Geometry geometry,
}

/**
* Update teh has z and m values
* Update the has z and m values
*
* @param envelope
* geometry envelope
* @param geometry
* geometry
*/
private static void updateHasZandM(GeometryEnvelope envelope,
Geometry geometry) {
Expand All @@ -126,9 +135,11 @@ private static void updateHasZandM(GeometryEnvelope envelope,
* Add Point
*
* @param envelope
* geometry envelope
* @param point
* point
*/
private static void addPointMessage(GeometryEnvelope envelope, Point point) {
private static void addPoint(GeometryEnvelope envelope, Point point) {

updateHasZandM(envelope, point);

Expand Down Expand Up @@ -174,117 +185,149 @@ private static void addPointMessage(GeometryEnvelope envelope, Point point) {
* Add MultiPoint
*
* @param envelope
* geometry envelope
* @param multiPoint
* multi point
*/
private static void addMultiPointMessage(GeometryEnvelope envelope,
private static void addMultiPoint(GeometryEnvelope envelope,
MultiPoint multiPoint) {

updateHasZandM(envelope, multiPoint);

List<Point> points = multiPoint.getPoints();
for (Point point : points) {
addPointMessage(envelope, point);
addPoint(envelope, point);
}
}

/**
* Add LineString
*
* @param envelope
* geometry envelope
* @param lineString
* line string
*/
private static void addLineStringMessage(GeometryEnvelope envelope,
private static void addLineString(GeometryEnvelope envelope,
LineString lineString) {

updateHasZandM(envelope, lineString);

for (Point point : lineString.getPoints()) {
addPointMessage(envelope, point);
addPoint(envelope, point);
}
}

/**
* Add MultiLineString
*
* @param envelope
* geometry envelope
* @param multiLineString
* multi line string
*/
private static void addMultiLineStringMessage(GeometryEnvelope envelope,
private static void addMultiLineString(GeometryEnvelope envelope,
MultiLineString multiLineString) {

updateHasZandM(envelope, multiLineString);

List<LineString> lineStrings = multiLineString.getLineStrings();
for (LineString lineString : lineStrings) {
addLineStringMessage(envelope, lineString);
addLineString(envelope, lineString);
}
}

/**
* Add Polygon
*
* @param envelope
* geometry envelope
* @param polygon
* polygon
*/
private static void addPolygonMessage(GeometryEnvelope envelope,
Polygon polygon) {
private static void addPolygon(GeometryEnvelope envelope, Polygon polygon) {

updateHasZandM(envelope, polygon);

List<LineString> rings = polygon.getRings();
for (LineString ring : rings) {
addLineStringMessage(envelope, ring);
addLineString(envelope, ring);
}
}

/**
* Add MultiPolygon
*
* @param envelope
* geometry envelope
* @param multiPolygon
* multi polygon
*/
private static void addMultiPolygonMessage(GeometryEnvelope envelope,
private static void addMultiPolygon(GeometryEnvelope envelope,
MultiPolygon multiPolygon) {

updateHasZandM(envelope, multiPolygon);

List<Polygon> polygons = multiPolygon.getPolygons();
for (Polygon polygon : polygons) {
addPolygonMessage(envelope, polygon);
addPolygon(envelope, polygon);
}
}

/**
* Add CompoundCurve
*
* @param envelope
* geometry envelope
* @param compoundCurve
* compound curve
*/
private static void addCompoundCurveMessage(GeometryEnvelope envelope,
private static void addCompoundCurve(GeometryEnvelope envelope,
CompoundCurve compoundCurve) {

updateHasZandM(envelope, compoundCurve);

List<LineString> lineStrings = compoundCurve.getLineStrings();
for (LineString lineString : lineStrings) {
addLineStringMessage(envelope, lineString);
addLineString(envelope, lineString);
}
}

/**
* Add CurvePolygon
*
* @param envelope
* geometry envelope
* @param curvePolygon
* curve polygon
*/
private static void addCurvePolygon(GeometryEnvelope envelope,
CurvePolygon<Curve> curvePolygon) {

updateHasZandM(envelope, curvePolygon);

List<Curve> rings = curvePolygon.getRings();
for (Curve ring : rings) {
buildEnvelope(ring, envelope);
}
}

/**
* Add PolyhedralSurface
*
* @param envelope
* geometry envelope
* @param polyhedralSurface
* polyhedral surface
*/
private static void addPolyhedralSurfaceMessage(GeometryEnvelope envelope,
private static void addPolyhedralSurface(GeometryEnvelope envelope,
PolyhedralSurface polyhedralSurface) {

updateHasZandM(envelope, polyhedralSurface);

List<Polygon> polygons = polyhedralSurface.getPolygons();
for (Polygon polygon : polygons) {
addPolygonMessage(envelope, polygon);
addPolygon(envelope, polygon);
}
}

Expand Down
Loading

0 comments on commit c9c60bc

Please sign in to comment.