├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── config.yml │ └── documentation-report.md └── workflows │ ├── build-test.yml │ └── build.yml ├── .gitignore ├── CHANGELOG.md ├── LICENSE.txt ├── README.md ├── docs ├── docs │ └── api │ │ ├── META-INF │ │ └── MANIFEST.MF │ │ ├── allclasses-index.html │ │ ├── allclasses.html │ │ ├── allpackages-index.html │ │ ├── constant-values.html │ │ ├── deprecated-list.html │ │ ├── element-list │ │ ├── help-doc.html │ │ ├── index-all.html │ │ ├── index.html │ │ ├── jquery │ │ ├── external │ │ │ └── jquery │ │ │ │ └── jquery.js │ │ ├── images │ │ │ ├── ui-bg_glass_55_fbf9ee_1x400.png │ │ │ ├── ui-bg_glass_65_dadada_1x400.png │ │ │ ├── ui-bg_glass_75_dadada_1x400.png │ │ │ ├── ui-bg_glass_75_e6e6e6_1x400.png │ │ │ ├── ui-bg_glass_95_fef1ec_1x400.png │ │ │ ├── ui-bg_highlight-soft_75_cccccc_1x100.png │ │ │ ├── ui-icons_222222_256x240.png │ │ │ ├── ui-icons_2e83ff_256x240.png │ │ │ ├── ui-icons_454545_256x240.png │ │ │ ├── ui-icons_888888_256x240.png │ │ │ └── ui-icons_cd0a0a_256x240.png │ │ ├── jquery-3.5.1.js │ │ ├── jquery-ui.css │ │ ├── jquery-ui.js │ │ ├── jquery-ui.min.css │ │ ├── jquery-ui.min.js │ │ ├── jquery-ui.structure.css │ │ ├── jquery-ui.structure.min.css │ │ ├── jszip-utils │ │ │ └── dist │ │ │ │ ├── jszip-utils-ie.js │ │ │ │ ├── jszip-utils-ie.min.js │ │ │ │ ├── jszip-utils.js │ │ │ │ └── jszip-utils.min.js │ │ └── jszip │ │ │ └── dist │ │ │ ├── jszip.js │ │ │ └── jszip.min.js │ │ ├── member-search-index.js │ │ ├── member-search-index.zip │ │ ├── mil │ │ └── nga │ │ │ └── sf │ │ │ ├── CircularString.html │ │ │ ├── CompoundCurve.html │ │ │ ├── Curve.html │ │ │ ├── CurvePolygon.html │ │ │ ├── Geometry.html │ │ │ ├── GeometryCollection.html │ │ │ ├── GeometryEnvelope.html │ │ │ ├── GeometryType.html │ │ │ ├── Line.html │ │ │ ├── LineString.html │ │ │ ├── LinearRing.html │ │ │ ├── MultiCurve.html │ │ │ ├── MultiLineString.html │ │ │ ├── MultiPoint.html │ │ │ ├── MultiPolygon.html │ │ │ ├── MultiSurface.html │ │ │ ├── Point.html │ │ │ ├── Polygon.html │ │ │ ├── PolyhedralSurface.html │ │ │ ├── Surface.html │ │ │ ├── TIN.html │ │ │ ├── Triangle.html │ │ │ ├── class-use │ │ │ ├── CircularString.html │ │ │ ├── CompoundCurve.html │ │ │ ├── Curve.html │ │ │ ├── CurvePolygon.html │ │ │ ├── Geometry.html │ │ │ ├── GeometryCollection.html │ │ │ ├── GeometryEnvelope.html │ │ │ ├── GeometryType.html │ │ │ ├── Line.html │ │ │ ├── LineString.html │ │ │ ├── LinearRing.html │ │ │ ├── MultiCurve.html │ │ │ ├── MultiLineString.html │ │ │ ├── MultiPoint.html │ │ │ ├── MultiPolygon.html │ │ │ ├── MultiSurface.html │ │ │ ├── Point.html │ │ │ ├── Polygon.html │ │ │ ├── PolyhedralSurface.html │ │ │ ├── Surface.html │ │ │ ├── TIN.html │ │ │ └── Triangle.html │ │ │ ├── extended │ │ │ ├── ExtendedGeometryCollection.html │ │ │ ├── class-use │ │ │ │ └── ExtendedGeometryCollection.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ └── package-use.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ ├── package-use.html │ │ │ └── util │ │ │ ├── ByteReader.html │ │ │ ├── ByteWriter.html │ │ │ ├── GeometryConstants.html │ │ │ ├── GeometryEnvelopeBuilder.html │ │ │ ├── GeometryPrinter.html │ │ │ ├── GeometryUtils.html │ │ │ ├── SFException.html │ │ │ ├── TextReader.html │ │ │ ├── centroid │ │ │ ├── CentroidCurve.html │ │ │ ├── CentroidPoint.html │ │ │ ├── CentroidSurface.html │ │ │ ├── DegreesCentroid.html │ │ │ ├── class-use │ │ │ │ ├── CentroidCurve.html │ │ │ │ ├── CentroidPoint.html │ │ │ │ ├── CentroidSurface.html │ │ │ │ └── DegreesCentroid.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ └── package-use.html │ │ │ ├── class-use │ │ │ ├── ByteReader.html │ │ │ ├── ByteWriter.html │ │ │ ├── GeometryConstants.html │ │ │ ├── GeometryEnvelopeBuilder.html │ │ │ ├── GeometryPrinter.html │ │ │ ├── GeometryUtils.html │ │ │ ├── SFException.html │ │ │ └── TextReader.html │ │ │ ├── filter │ │ │ ├── FiniteFilterType.html │ │ │ ├── GeometryFilter.html │ │ │ ├── PointFiniteFilter.html │ │ │ ├── class-use │ │ │ │ ├── FiniteFilterType.html │ │ │ │ ├── GeometryFilter.html │ │ │ │ └── PointFiniteFilter.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ └── package-use.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ ├── package-use.html │ │ │ └── sweep │ │ │ ├── Event.html │ │ │ ├── EventQueue.html │ │ │ ├── EventType.html │ │ │ ├── Segment.html │ │ │ ├── ShamosHoey.html │ │ │ ├── SweepLine.html │ │ │ ├── class-use │ │ │ ├── Event.html │ │ │ ├── EventQueue.html │ │ │ ├── EventType.html │ │ │ ├── Segment.html │ │ │ ├── ShamosHoey.html │ │ │ └── SweepLine.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ └── package-use.html │ │ ├── overview-summary.html │ │ ├── overview-tree.html │ │ ├── package-search-index.js │ │ ├── package-search-index.zip │ │ ├── resources │ │ ├── glass.png │ │ └── x.png │ │ ├── script.js │ │ ├── search.js │ │ ├── serialized-form.html │ │ ├── stylesheet.css │ │ ├── type-search-index.js │ │ └── type-search-index.zip ├── index.html └── stylesheets │ ├── github-light.css │ ├── normalize.css │ └── stylesheet.css ├── pom.xml └── src ├── main └── java │ └── mil │ └── nga │ └── sf │ ├── CircularString.java │ ├── CompoundCurve.java │ ├── Curve.java │ ├── CurvePolygon.java │ ├── Geometry.java │ ├── GeometryCollection.java │ ├── GeometryEnvelope.java │ ├── GeometryType.java │ ├── Line.java │ ├── LineString.java │ ├── LinearRing.java │ ├── MultiCurve.java │ ├── MultiLineString.java │ ├── MultiPoint.java │ ├── MultiPolygon.java │ ├── MultiSurface.java │ ├── Point.java │ ├── Polygon.java │ ├── PolyhedralSurface.java │ ├── Surface.java │ ├── TIN.java │ ├── Triangle.java │ ├── extended │ └── ExtendedGeometryCollection.java │ └── util │ ├── ByteReader.java │ ├── ByteWriter.java │ ├── GeometryConstants.java │ ├── GeometryEnvelopeBuilder.java │ ├── GeometryPrinter.java │ ├── GeometryUtils.java │ ├── SFException.java │ ├── TextReader.java │ ├── centroid │ ├── CentroidCurve.java │ ├── CentroidPoint.java │ ├── CentroidSurface.java │ └── DegreesCentroid.java │ ├── filter │ ├── FiniteFilterType.java │ ├── GeometryFilter.java │ └── PointFiniteFilter.java │ └── sweep │ ├── Event.java │ ├── EventQueue.java │ ├── EventType.java │ ├── Segment.java │ ├── ShamosHoey.java │ └── SweepLine.java └── test └── java └── mil └── nga └── sf ├── GeometryCollectionTest.java ├── GeometrySerializableTest.java ├── GeometryUtilsTest.java ├── SFTestUtils.java └── util └── sweep └── ShamosHoeyTest.java /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Report an issue 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | Please fill out as much known and relevant information as possible. 11 | 12 | #### Version Information: 13 | 14 | * SF Java Version: 15 | * SF Java Source: (e.g. Central Repository, Release, Source Code Build) 16 | * IDE Name & Version: 17 | * Maven Version: (mvn -version) 18 | * Java Version: (java -version) 19 | * Platform & OS: 20 | * Other Relevant Libraries: 21 | 22 | #### Expected Results: 23 | 24 | * What did you expect to happen? 25 | 26 | #### Observed Results: 27 | 28 | * What happened instead? 29 | * How often does this occur? 30 | 31 | #### Output: 32 | 33 | * Any logs, errors, or output messages? 34 | 35 | #### Steps to Reproduce: 36 | 37 | 1. Step One 38 | 2. Step Two 39 | 3. ... 40 | 41 | #### Relevant Code: 42 | 43 | ```java 44 | // Code to reproduce the problem? 45 | ``` 46 | 47 | #### Test Files: 48 | 49 | * Links to any files needed for testing? 50 | 51 | #### Additional Information: 52 | 53 | * Any additional configuration, data, or information that might help with the issue? 54 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | 2 | blank_issues_enabled: false 3 | contact_links: 4 | - name: Discussions 5 | url: https://github.com/ngageoint/simple-features-java/discussions 6 | about: Questions, Feature Requests, Feedback, Conversations 7 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/documentation-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Documentation report 3 | about: Report a documentation issue 4 | title: '' 5 | labels: documentation 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the documentation issue** 11 | A clear and concise description of what the issue is. 12 | 13 | **Additional context** 14 | Add any other context about the issue here. 15 | -------------------------------------------------------------------------------- /.github/workflows/build-test.yml: -------------------------------------------------------------------------------- 1 | name: Build & Test 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | 9 | jobs: 10 | 11 | build: 12 | 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - name: Checkout Repository 17 | uses: actions/checkout@v3 18 | - name: Set up JDK 11 19 | uses: actions/setup-java@v3 20 | with: 21 | distribution: 'temurin' 22 | java-version: 11 23 | - name: Build & Test 24 | run: mvn clean package 25 | - name: Copy Release Artifacts 26 | run: | 27 | mkdir target/release 28 | cp pom.xml target/*.jar target/release/ 29 | - name: Upload Artifacts 30 | uses: actions/upload-artifact@v1 31 | with: 32 | name: simple-features 33 | path: target/release 34 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | branches-ignore: 6 | - master 7 | 8 | jobs: 9 | 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - name: Checkout Repository 16 | uses: actions/checkout@v3 17 | - name: Set up JDK 11 18 | uses: actions/setup-java@v3 19 | with: 20 | distribution: 'temurin' 21 | java-version: 11 22 | - name: Build 23 | run: mvn clean package -DskipTests 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /bin/ 3 | 4 | # IntelliJ 5 | .idea 6 | *.iml 7 | 8 | # Eclipse Core 9 | .project 10 | .settings/ 11 | 12 | # JDT-specific (Eclipse Java Development Tools) 13 | .classpath 14 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. 3 | Adheres to [Semantic Versioning](http://semver.org/). 4 | 5 | --- 6 | 7 | ## 2.2.3 (TBD) 8 | 9 | * TBD 10 | 11 | ## [2.2.2](https://github.com/ngageoint/simple-features-java/releases/tag/2.2.2) (04-02-2024) 12 | 13 | * Geometry Utils for Haversine distance, geodesic midpoints, geodesic paths, and geodesic envelopes 14 | * Envelope left mid, bottom mid, right mid, and top mid methods 15 | 16 | ## [2.2.1](https://github.com/ngageoint/simple-features-java/releases/tag/2.2.1) (01-19-2023) 17 | 18 | * Shamos-Hoey simple polygon detection bug fix 19 | 20 | ## [2.2.0](https://github.com/ngageoint/simple-features-java/releases/tag/2.2.0) (09-21-2022) 21 | 22 | * GeometryEnvelope directionals and contains methods 23 | * Geometry constants 24 | * Line two point constructor 25 | * Geometry utility distance, bearings, conversions, minimize, normalize, envelopes, crop, equal, contains, and bound 26 | 27 | ## [2.1.0](https://github.com/ngageoint/simple-features-java/releases/tag/2.1.0) (07-08-2022) 28 | 29 | * Geometry utilities for line intersections and degree to/from meter conversions 30 | * GeometryEnvelope serializable and methods for mid values, is empty, and contains 31 | 32 | ## [2.0.6](https://github.com/ngageoint/simple-features-java/releases/tag/2.0.6) (04-18-2022) 33 | 34 | * Text token reader handling of non whitespace space characters such as 'NO-BREAK SPACE' 35 | 36 | ## [2.0.5](https://github.com/ngageoint/simple-features-java/releases/tag/2.0.5) (02-03-2022) 37 | 38 | * GeometryEnvelope range, point check, centroid, and build geometry utilities 39 | * Geometry expand envelope method 40 | * Centroid geometry utility for geometries in degrees 41 | * Java 11 42 | 43 | ## [2.0.4](https://github.com/ngageoint/simple-features-java/releases/tag/2.0.4) (03-03-2021) 44 | 45 | * Text token reader support for '+' 46 | 47 | ## [2.0.3](https://github.com/ngageoint/simple-features-java/releases/tag/2.0.3) (07-13-2020) 48 | 49 | * Geometry Filter interface and Point Finite Filter implementation 50 | * Manual and automatic z and m has value updates 51 | * Byte Reader/Writer Input/Output stream backing 52 | * Text token reader 53 | 54 | ## [2.0.2](https://github.com/ngageoint/simple-features-java/releases/tag/2.0.2) (07-08-2019) 55 | 56 | * Geometry Type find by name method 57 | 58 | ## [2.0.1](https://github.com/ngageoint/simple-features-java/releases/tag/2.0.1) (04-01-2019) 59 | 60 | * Geometry Type parent and child hierarchy utility methods 61 | * Serializable geometries 62 | * Serialize and deserialize geometry utility methods 63 | * Geometry Envelope intersects, contains, and overlap while allowing empty 64 | * 2D Centroid documentation clarification 65 | * Eclipse project cleanup 66 | 67 | ## [2.0.0](https://github.com/ngageoint/simple-features-java/releases/tag/2.0.0) (05-17-2018) 68 | 69 | * Initial Release 70 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Bit Systems 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Simple Features Java 2 | 3 | #### Simple Features Lib #### 4 | 5 | The Simple Features Libraries were developed at the [National Geospatial-Intelligence Agency (NGA)](http://www.nga.mil/) in collaboration with [BIT Systems](https://www.caci.com/bit-systems/). The government has "unlimited rights" and is releasing this software to increase the impact of government investments by providing developers with the opportunity to take things in new directions. The software use, modification, and distribution rights are stipulated within the [MIT license](http://choosealicense.com/licenses/mit/). 6 | 7 | ### Pull Requests ### 8 | If you'd like to contribute to this project, please make a pull request. We'll review the pull request and discuss the changes. All pull request contributions to this project will be released under the MIT license. 9 | 10 | Software source code previously released under an open source license and then modified by NGA staff is considered a "joint work" (see 17 USC § 101); it is partially copyrighted, partially public domain, and as a whole is protected by the copyrights of the non-government authors and must be released according to the terms of the original open source license. 11 | 12 | ### About ### 13 | 14 | [Simple Features](http://ngageoint.github.io/simple-features-java/) is a Java library of geometry objects and utilities based upon the [OGC Simple Feature Access](http://www.opengeospatial.org/standards/sfa) standard. 15 | 16 | ### Simple Feature Conversion Libraries ### 17 | 18 | * [simple-features-wkb-java](https://github.com/ngageoint/simple-features-wkb-java) - Well Known Binary 19 | * [simple-features-wkt-java](https://github.com/ngageoint/simple-features-wkt-java) - Well Known Text 20 | * [simple-features-geojson-java](https://github.com/ngageoint/simple-features-geojson-java) - GeoJSON 21 | * [simple-features-proj-java](https://github.com/ngageoint/simple-features-proj-java) - Projection 22 | 23 | ### Usage ### 24 | 25 | View the latest [Javadoc](http://ngageoint.github.io/simple-features-java/docs/api/) 26 | 27 | ### Installation ### 28 | 29 | Pull from the [Maven Central Repository](http://search.maven.org/#artifactdetails|mil.nga|sf|2.2.2|jar) (JAR, POM, Source, Javadoc) 30 | 31 | ```xml 32 | 33 | 34 | mil.nga 35 | sf 36 | 2.2.2 37 | 38 | 39 | ``` 40 | 41 | ### Build ### 42 | 43 | [![Build & Test](https://github.com/ngageoint/simple-features-java/workflows/Build%20&%20Test/badge.svg)](https://github.com/ngageoint/simple-features-java/actions/workflows/build-test.yml) 44 | 45 | Build this repository using Eclipse and/or Maven: 46 | 47 | mvn clean install 48 | -------------------------------------------------------------------------------- /docs/docs/api/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Created-By: Maven Javadoc Plugin 3.6.3 3 | Build-Jdk-Spec: 11 4 | 5 | -------------------------------------------------------------------------------- /docs/docs/api/allclasses.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | All Classes (Simple Features 2.2.2 API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 |

All Classes

22 |
23 | 69 |
70 | 71 | 72 | -------------------------------------------------------------------------------- /docs/docs/api/deprecated-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Deprecated List (Simple Features 2.2.2 API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 33 | 36 |
37 | 94 |
95 |
96 |
97 |

Deprecated API

98 |

Contents

99 |
100 |
101 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /docs/docs/api/element-list: -------------------------------------------------------------------------------- 1 | mil.nga.sf 2 | mil.nga.sf.extended 3 | mil.nga.sf.util 4 | mil.nga.sf.util.centroid 5 | mil.nga.sf.util.filter 6 | mil.nga.sf.util.sweep 7 | -------------------------------------------------------------------------------- /docs/docs/api/jquery/images/ui-bg_glass_55_fbf9ee_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngageoint/simple-features-java/34f60033d7f843aa429e73959f7ff1f9e593d5ad/docs/docs/api/jquery/images/ui-bg_glass_55_fbf9ee_1x400.png -------------------------------------------------------------------------------- /docs/docs/api/jquery/images/ui-bg_glass_65_dadada_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngageoint/simple-features-java/34f60033d7f843aa429e73959f7ff1f9e593d5ad/docs/docs/api/jquery/images/ui-bg_glass_65_dadada_1x400.png -------------------------------------------------------------------------------- /docs/docs/api/jquery/images/ui-bg_glass_75_dadada_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngageoint/simple-features-java/34f60033d7f843aa429e73959f7ff1f9e593d5ad/docs/docs/api/jquery/images/ui-bg_glass_75_dadada_1x400.png -------------------------------------------------------------------------------- /docs/docs/api/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngageoint/simple-features-java/34f60033d7f843aa429e73959f7ff1f9e593d5ad/docs/docs/api/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png -------------------------------------------------------------------------------- /docs/docs/api/jquery/images/ui-bg_glass_95_fef1ec_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngageoint/simple-features-java/34f60033d7f843aa429e73959f7ff1f9e593d5ad/docs/docs/api/jquery/images/ui-bg_glass_95_fef1ec_1x400.png -------------------------------------------------------------------------------- /docs/docs/api/jquery/images/ui-bg_highlight-soft_75_cccccc_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngageoint/simple-features-java/34f60033d7f843aa429e73959f7ff1f9e593d5ad/docs/docs/api/jquery/images/ui-bg_highlight-soft_75_cccccc_1x100.png -------------------------------------------------------------------------------- /docs/docs/api/jquery/images/ui-icons_222222_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngageoint/simple-features-java/34f60033d7f843aa429e73959f7ff1f9e593d5ad/docs/docs/api/jquery/images/ui-icons_222222_256x240.png -------------------------------------------------------------------------------- /docs/docs/api/jquery/images/ui-icons_2e83ff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngageoint/simple-features-java/34f60033d7f843aa429e73959f7ff1f9e593d5ad/docs/docs/api/jquery/images/ui-icons_2e83ff_256x240.png -------------------------------------------------------------------------------- /docs/docs/api/jquery/images/ui-icons_454545_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngageoint/simple-features-java/34f60033d7f843aa429e73959f7ff1f9e593d5ad/docs/docs/api/jquery/images/ui-icons_454545_256x240.png -------------------------------------------------------------------------------- /docs/docs/api/jquery/images/ui-icons_888888_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngageoint/simple-features-java/34f60033d7f843aa429e73959f7ff1f9e593d5ad/docs/docs/api/jquery/images/ui-icons_888888_256x240.png -------------------------------------------------------------------------------- /docs/docs/api/jquery/images/ui-icons_cd0a0a_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngageoint/simple-features-java/34f60033d7f843aa429e73959f7ff1f9e593d5ad/docs/docs/api/jquery/images/ui-icons_cd0a0a_256x240.png -------------------------------------------------------------------------------- /docs/docs/api/jquery/jquery-ui.structure.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery UI CSS Framework 1.12.1 3 | * http://jqueryui.com 4 | * 5 | * Copyright jQuery Foundation and other contributors 6 | * Released under the MIT license. 7 | * http://jquery.org/license 8 | * 9 | * http://api.jqueryui.com/category/theming/ 10 | */ 11 | /* Layout helpers 12 | ----------------------------------*/ 13 | .ui-helper-hidden { 14 | display: none; 15 | } 16 | .ui-helper-hidden-accessible { 17 | border: 0; 18 | clip: rect(0 0 0 0); 19 | height: 1px; 20 | margin: -1px; 21 | overflow: hidden; 22 | padding: 0; 23 | position: absolute; 24 | width: 1px; 25 | } 26 | .ui-helper-reset { 27 | margin: 0; 28 | padding: 0; 29 | border: 0; 30 | outline: 0; 31 | line-height: 1.3; 32 | text-decoration: none; 33 | font-size: 100%; 34 | list-style: none; 35 | } 36 | .ui-helper-clearfix:before, 37 | .ui-helper-clearfix:after { 38 | content: ""; 39 | display: table; 40 | border-collapse: collapse; 41 | } 42 | .ui-helper-clearfix:after { 43 | clear: both; 44 | } 45 | .ui-helper-zfix { 46 | width: 100%; 47 | height: 100%; 48 | top: 0; 49 | left: 0; 50 | position: absolute; 51 | opacity: 0; 52 | filter:Alpha(Opacity=0); /* support: IE8 */ 53 | } 54 | 55 | .ui-front { 56 | z-index: 100; 57 | } 58 | 59 | 60 | /* Interaction Cues 61 | ----------------------------------*/ 62 | .ui-state-disabled { 63 | cursor: default !important; 64 | pointer-events: none; 65 | } 66 | 67 | 68 | /* Icons 69 | ----------------------------------*/ 70 | .ui-icon { 71 | display: inline-block; 72 | vertical-align: middle; 73 | margin-top: -.25em; 74 | position: relative; 75 | text-indent: -99999px; 76 | overflow: hidden; 77 | background-repeat: no-repeat; 78 | } 79 | 80 | .ui-widget-icon-block { 81 | left: 50%; 82 | margin-left: -8px; 83 | display: block; 84 | } 85 | 86 | /* Misc visuals 87 | ----------------------------------*/ 88 | 89 | /* Overlays */ 90 | .ui-widget-overlay { 91 | position: fixed; 92 | top: 0; 93 | left: 0; 94 | width: 100%; 95 | height: 100%; 96 | } 97 | .ui-autocomplete { 98 | position: absolute; 99 | top: 0; 100 | left: 0; 101 | cursor: default; 102 | } 103 | .ui-menu { 104 | list-style: none; 105 | padding: 0; 106 | margin: 0; 107 | display: block; 108 | outline: 0; 109 | } 110 | .ui-menu .ui-menu { 111 | position: absolute; 112 | } 113 | .ui-menu .ui-menu-item { 114 | margin: 0; 115 | cursor: pointer; 116 | /* support: IE10, see #8844 */ 117 | list-style-image: url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"); 118 | } 119 | .ui-menu .ui-menu-item-wrapper { 120 | position: relative; 121 | padding: 3px 1em 3px .4em; 122 | } 123 | .ui-menu .ui-menu-divider { 124 | margin: 5px 0; 125 | height: 0; 126 | font-size: 0; 127 | line-height: 0; 128 | border-width: 1px 0 0 0; 129 | } 130 | .ui-menu .ui-state-focus, 131 | .ui-menu .ui-state-active { 132 | margin: -1px; 133 | } 134 | 135 | /* icon support */ 136 | .ui-menu-icons { 137 | position: relative; 138 | } 139 | .ui-menu-icons .ui-menu-item-wrapper { 140 | padding-left: 2em; 141 | } 142 | 143 | /* left-aligned */ 144 | .ui-menu .ui-icon { 145 | position: absolute; 146 | top: 0; 147 | bottom: 0; 148 | left: .2em; 149 | margin: auto 0; 150 | } 151 | 152 | /* right-aligned */ 153 | .ui-menu .ui-menu-icon { 154 | left: auto; 155 | right: 0; 156 | } 157 | -------------------------------------------------------------------------------- /docs/docs/api/jquery/jquery-ui.structure.min.css: -------------------------------------------------------------------------------- 1 | /*! jQuery UI - v1.12.1 - 2018-12-06 2 | * http://jqueryui.com 3 | * Copyright jQuery Foundation and other contributors; Licensed MIT */ 4 | 5 | .ui-helper-hidden{display:none}.ui-helper-hidden-accessible{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:before,.ui-helper-clearfix:after{content:"";display:table;border-collapse:collapse}.ui-helper-clearfix:after{clear:both}.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-front{z-index:100}.ui-state-disabled{cursor:default!important;pointer-events:none}.ui-icon{display:inline-block;vertical-align:middle;margin-top:-.25em;position:relative;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-icon-block{left:50%;margin-left:-8px;display:block}.ui-widget-overlay{position:fixed;top:0;left:0;width:100%;height:100%}.ui-autocomplete{position:absolute;top:0;left:0;cursor:default}.ui-menu{list-style:none;padding:0;margin:0;display:block;outline:0}.ui-menu .ui-menu{position:absolute}.ui-menu .ui-menu-item{margin:0;cursor:pointer;list-style-image:url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7")}.ui-menu .ui-menu-item-wrapper{position:relative;padding:3px 1em 3px .4em}.ui-menu .ui-menu-divider{margin:5px 0;height:0;font-size:0;line-height:0;border-width:1px 0 0 0}.ui-menu .ui-state-focus,.ui-menu .ui-state-active{margin:-1px}.ui-menu-icons{position:relative}.ui-menu-icons .ui-menu-item-wrapper{padding-left:2em}.ui-menu .ui-icon{position:absolute;top:0;bottom:0;left:.2em;margin:auto 0}.ui-menu .ui-menu-icon{left:auto;right:0} -------------------------------------------------------------------------------- /docs/docs/api/jquery/jszip-utils/dist/jszip-utils-ie.js: -------------------------------------------------------------------------------- 1 | /*! 2 | 3 | JSZipUtils - A collection of cross-browser utilities to go along with JSZip. 4 | 5 | 6 | (c) 2014 Stuart Knightley, David Duponchel 7 | Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip-utils/master/LICENSE.markdown. 8 | 9 | */ 10 | ;(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o\r\n"+ 18 | "\r\n"; 32 | 33 | // inject VBScript 34 | document.write(IEBinaryToArray_ByteStr_Script); 35 | 36 | global.JSZipUtils._getBinaryFromXHR = function (xhr) { 37 | var binary = xhr.responseBody; 38 | var byteMapping = {}; 39 | for ( var i = 0; i < 256; i++ ) { 40 | for ( var j = 0; j < 256; j++ ) { 41 | byteMapping[ String.fromCharCode( i + (j << 8) ) ] = 42 | String.fromCharCode(i) + String.fromCharCode(j); 43 | } 44 | } 45 | var rawBytes = IEBinaryToArray_ByteStr(binary); 46 | var lastChr = IEBinaryToArray_ByteStr_Last(binary); 47 | return rawBytes.replace(/[\s\S]/g, function( match ) { 48 | return byteMapping[match]; 49 | }) + lastChr; 50 | }; 51 | 52 | // enforcing Stuk's coding style 53 | // vim: set shiftwidth=4 softtabstop=4: 54 | 55 | },{}]},{},[1]) 56 | ; 57 | -------------------------------------------------------------------------------- /docs/docs/api/jquery/jszip-utils/dist/jszip-utils-ie.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | 3 | JSZipUtils - A collection of cross-browser utilities to go along with JSZip. 4 | 5 | 6 | (c) 2014 Stuart Knightley, David Duponchel 7 | Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip-utils/master/LICENSE.markdown. 8 | 9 | */ 10 | !function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g\r\n";document.write(b),a.JSZipUtils._getBinaryFromXHR=function(a){for(var b=a.responseBody,c={},d=0;256>d;d++)for(var e=0;256>e;e++)c[String.fromCharCode(d+(e<<8))]=String.fromCharCode(d)+String.fromCharCode(e);var f=IEBinaryToArray_ByteStr(b),g=IEBinaryToArray_ByteStr_Last(b);return f.replace(/[\s\S]/g,function(a){return c[a]})+g}},{}]},{},[1]); 11 | -------------------------------------------------------------------------------- /docs/docs/api/jquery/jszip-utils/dist/jszip-utils.js: -------------------------------------------------------------------------------- 1 | /*! 2 | 3 | JSZipUtils - A collection of cross-browser utilities to go along with JSZip. 4 | 5 | 6 | (c) 2014 Stuart Knightley, David Duponchel 7 | Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip-utils/master/LICENSE.markdown. 8 | 9 | */ 10 | !function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.JSZipUtils=e():"undefined"!=typeof global?global.JSZipUtils=e():"undefined"!=typeof self&&(self.JSZipUtils=e())}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 5 | 6 | (c) 2014 Stuart Knightley, David Duponchel 7 | Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip-utils/master/LICENSE.markdown. 8 | 9 | */ 10 | !function(a){"object"==typeof exports?module.exports=a():"function"==typeof define&&define.amd?define(a):"undefined"!=typeof window?window.JSZipUtils=a():"undefined"!=typeof global?global.JSZipUtils=a():"undefined"!=typeof self&&(self.JSZipUtils=a())}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g 2 | 3 | 4 | 5 | 6 | Uses of Package mil.nga.sf.util.centroid (Simple Features 2.2.2 API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 33 | 36 |
37 | 94 |
95 |
96 |
97 |

Uses of Package
mil.nga.sf.util.centroid

98 |
99 |
No usage of mil.nga.sf.util.centroid
100 |
101 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /docs/docs/api/mil/nga/sf/util/class-use/ByteReader.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class mil.nga.sf.util.ByteReader (Simple Features 2.2.2 API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 33 | 36 |
37 | 94 |
95 |
96 |
97 |

Uses of Class
mil.nga.sf.util.ByteReader

98 |
99 |
No usage of mil.nga.sf.util.ByteReader
100 |
101 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /docs/docs/api/mil/nga/sf/util/class-use/ByteWriter.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class mil.nga.sf.util.ByteWriter (Simple Features 2.2.2 API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 33 | 36 |
37 | 94 |
95 |
96 |
97 |

Uses of Class
mil.nga.sf.util.ByteWriter

98 |
99 |
No usage of mil.nga.sf.util.ByteWriter
100 |
101 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /docs/docs/api/mil/nga/sf/util/class-use/GeometryConstants.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class mil.nga.sf.util.GeometryConstants (Simple Features 2.2.2 API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 33 | 36 |
37 | 94 |
95 |
96 |
97 |

Uses of Class
mil.nga.sf.util.GeometryConstants

98 |
99 |
No usage of mil.nga.sf.util.GeometryConstants
100 |
101 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /docs/docs/api/mil/nga/sf/util/class-use/GeometryEnvelopeBuilder.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class mil.nga.sf.util.GeometryEnvelopeBuilder (Simple Features 2.2.2 API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 33 | 36 |
37 | 94 |
95 |
96 |
97 |

Uses of Class
mil.nga.sf.util.GeometryEnvelopeBuilder

98 |
99 |
No usage of mil.nga.sf.util.GeometryEnvelopeBuilder
100 |
101 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /docs/docs/api/mil/nga/sf/util/class-use/GeometryPrinter.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class mil.nga.sf.util.GeometryPrinter (Simple Features 2.2.2 API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 33 | 36 |
37 | 94 |
95 |
96 |
97 |

Uses of Class
mil.nga.sf.util.GeometryPrinter

98 |
99 |
No usage of mil.nga.sf.util.GeometryPrinter
100 |
101 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /docs/docs/api/mil/nga/sf/util/class-use/GeometryUtils.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class mil.nga.sf.util.GeometryUtils (Simple Features 2.2.2 API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 33 | 36 |
37 | 94 |
95 |
96 |
97 |

Uses of Class
mil.nga.sf.util.GeometryUtils

98 |
99 |
No usage of mil.nga.sf.util.GeometryUtils
100 |
101 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /docs/docs/api/mil/nga/sf/util/class-use/SFException.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class mil.nga.sf.util.SFException (Simple Features 2.2.2 API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 33 | 36 |
37 | 94 |
95 |
96 |
97 |

Uses of Class
mil.nga.sf.util.SFException

98 |
99 |
No usage of mil.nga.sf.util.SFException
100 |
101 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /docs/docs/api/mil/nga/sf/util/class-use/TextReader.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class mil.nga.sf.util.TextReader (Simple Features 2.2.2 API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 33 | 36 |
37 | 94 |
95 |
96 |
97 |

Uses of Class
mil.nga.sf.util.TextReader

98 |
99 |
No usage of mil.nga.sf.util.TextReader
100 |
101 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /docs/docs/api/mil/nga/sf/util/package-use.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Package mil.nga.sf.util (Simple Features 2.2.2 API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 33 | 36 |
37 | 94 |
95 |
96 |
97 |

Uses of Package
mil.nga.sf.util

98 |
99 |
No usage of mil.nga.sf.util
100 |
101 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /docs/docs/api/mil/nga/sf/util/sweep/class-use/EventQueue.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class mil.nga.sf.util.sweep.EventQueue (Simple Features 2.2.2 API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 33 | 36 |
37 | 94 |
95 |
96 |
97 |

Uses of Class
mil.nga.sf.util.sweep.EventQueue

98 |
99 |
No usage of mil.nga.sf.util.sweep.EventQueue
100 |
101 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /docs/docs/api/mil/nga/sf/util/sweep/class-use/SweepLine.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class mil.nga.sf.util.sweep.SweepLine (Simple Features 2.2.2 API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 33 | 36 |
37 | 94 |
95 |
96 |
97 |

Uses of Class
mil.nga.sf.util.sweep.SweepLine

98 |
99 |
No usage of mil.nga.sf.util.sweep.SweepLine
100 |
101 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /docs/docs/api/overview-summary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Simple Features 2.2.2 API 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 |
17 | 20 |

index.html

21 |
22 | 23 | 24 | -------------------------------------------------------------------------------- /docs/docs/api/package-search-index.js: -------------------------------------------------------------------------------- 1 | packageSearchIndex = [{"l":"All Packages","url":"allpackages-index.html"},{"l":"mil.nga.sf"},{"l":"mil.nga.sf.extended"},{"l":"mil.nga.sf.util"},{"l":"mil.nga.sf.util.centroid"},{"l":"mil.nga.sf.util.filter"},{"l":"mil.nga.sf.util.sweep"}] -------------------------------------------------------------------------------- /docs/docs/api/package-search-index.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngageoint/simple-features-java/34f60033d7f843aa429e73959f7ff1f9e593d5ad/docs/docs/api/package-search-index.zip -------------------------------------------------------------------------------- /docs/docs/api/resources/glass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngageoint/simple-features-java/34f60033d7f843aa429e73959f7ff1f9e593d5ad/docs/docs/api/resources/glass.png -------------------------------------------------------------------------------- /docs/docs/api/resources/x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngageoint/simple-features-java/34f60033d7f843aa429e73959f7ff1f9e593d5ad/docs/docs/api/resources/x.png -------------------------------------------------------------------------------- /docs/docs/api/script.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | var moduleSearchIndex; 27 | var packageSearchIndex; 28 | var typeSearchIndex; 29 | var memberSearchIndex; 30 | var tagSearchIndex; 31 | function loadScripts(doc, tag) { 32 | createElem(doc, tag, 'jquery/jszip/dist/jszip.js'); 33 | createElem(doc, tag, 'jquery/jszip-utils/dist/jszip-utils.js'); 34 | if (window.navigator.userAgent.indexOf('MSIE ') > 0 || window.navigator.userAgent.indexOf('Trident/') > 0 || 35 | window.navigator.userAgent.indexOf('Edge/') > 0) { 36 | createElem(doc, tag, 'jquery/jszip-utils/dist/jszip-utils-ie.js'); 37 | } 38 | createElem(doc, tag, 'search.js'); 39 | 40 | $.get(pathtoroot + "module-search-index.zip") 41 | .done(function() { 42 | JSZipUtils.getBinaryContent(pathtoroot + "module-search-index.zip", function(e, data) { 43 | JSZip.loadAsync(data).then(function(zip){ 44 | zip.file("module-search-index.json").async("text").then(function(content){ 45 | moduleSearchIndex = JSON.parse(content); 46 | }); 47 | }); 48 | }); 49 | }); 50 | $.get(pathtoroot + "package-search-index.zip") 51 | .done(function() { 52 | JSZipUtils.getBinaryContent(pathtoroot + "package-search-index.zip", function(e, data) { 53 | JSZip.loadAsync(data).then(function(zip){ 54 | zip.file("package-search-index.json").async("text").then(function(content){ 55 | packageSearchIndex = JSON.parse(content); 56 | }); 57 | }); 58 | }); 59 | }); 60 | $.get(pathtoroot + "type-search-index.zip") 61 | .done(function() { 62 | JSZipUtils.getBinaryContent(pathtoroot + "type-search-index.zip", function(e, data) { 63 | JSZip.loadAsync(data).then(function(zip){ 64 | zip.file("type-search-index.json").async("text").then(function(content){ 65 | typeSearchIndex = JSON.parse(content); 66 | }); 67 | }); 68 | }); 69 | }); 70 | $.get(pathtoroot + "member-search-index.zip") 71 | .done(function() { 72 | JSZipUtils.getBinaryContent(pathtoroot + "member-search-index.zip", function(e, data) { 73 | JSZip.loadAsync(data).then(function(zip){ 74 | zip.file("member-search-index.json").async("text").then(function(content){ 75 | memberSearchIndex = JSON.parse(content); 76 | }); 77 | }); 78 | }); 79 | }); 80 | $.get(pathtoroot + "tag-search-index.zip") 81 | .done(function() { 82 | JSZipUtils.getBinaryContent(pathtoroot + "tag-search-index.zip", function(e, data) { 83 | JSZip.loadAsync(data).then(function(zip){ 84 | zip.file("tag-search-index.json").async("text").then(function(content){ 85 | tagSearchIndex = JSON.parse(content); 86 | }); 87 | }); 88 | }); 89 | }); 90 | if (!moduleSearchIndex) { 91 | createElem(doc, tag, 'module-search-index.js'); 92 | } 93 | if (!packageSearchIndex) { 94 | createElem(doc, tag, 'package-search-index.js'); 95 | } 96 | if (!typeSearchIndex) { 97 | createElem(doc, tag, 'type-search-index.js'); 98 | } 99 | if (!memberSearchIndex) { 100 | createElem(doc, tag, 'member-search-index.js'); 101 | } 102 | if (!tagSearchIndex) { 103 | createElem(doc, tag, 'tag-search-index.js'); 104 | } 105 | $(window).resize(function() { 106 | $('.navPadding').css('padding-top', $('.fixedNav').css("height")); 107 | }); 108 | } 109 | 110 | function createElem(doc, tag, path) { 111 | var script = doc.createElement(tag); 112 | var scriptElement = doc.getElementsByTagName(tag)[0]; 113 | script.src = pathtoroot + path; 114 | scriptElement.parentNode.insertBefore(script, scriptElement); 115 | } 116 | 117 | function show(type) { 118 | count = 0; 119 | for (var key in data) { 120 | var row = document.getElementById(key); 121 | if ((data[key] & type) !== 0) { 122 | row.style.display = ''; 123 | row.className = (count++ % 2) ? rowColor : altColor; 124 | } 125 | else 126 | row.style.display = 'none'; 127 | } 128 | updateTabs(type); 129 | } 130 | 131 | function updateTabs(type) { 132 | for (var value in tabs) { 133 | var sNode = document.getElementById(tabs[value][0]); 134 | var spanNode = sNode.firstChild; 135 | if (value == type) { 136 | sNode.className = activeTableTab; 137 | spanNode.innerHTML = tabs[value][1]; 138 | } 139 | else { 140 | sNode.className = tableTab; 141 | spanNode.innerHTML = "" + tabs[value][1] + ""; 142 | } 143 | } 144 | } 145 | 146 | function updateModuleFrame(pFrame, cFrame) { 147 | top.packageFrame.location = pFrame; 148 | top.classFrame.location = cFrame; 149 | } 150 | -------------------------------------------------------------------------------- /docs/docs/api/type-search-index.js: -------------------------------------------------------------------------------- 1 | typeSearchIndex = [{"l":"All Classes","url":"allclasses-index.html"},{"p":"mil.nga.sf.util","l":"ByteReader"},{"p":"mil.nga.sf.util","l":"ByteWriter"},{"p":"mil.nga.sf.util.centroid","l":"CentroidCurve"},{"p":"mil.nga.sf.util.centroid","l":"CentroidPoint"},{"p":"mil.nga.sf.util.centroid","l":"CentroidSurface"},{"p":"mil.nga.sf","l":"CircularString"},{"p":"mil.nga.sf","l":"CompoundCurve"},{"p":"mil.nga.sf","l":"Curve"},{"p":"mil.nga.sf","l":"CurvePolygon"},{"p":"mil.nga.sf.util.centroid","l":"DegreesCentroid"},{"p":"mil.nga.sf.util.sweep","l":"Event"},{"p":"mil.nga.sf.util.sweep","l":"EventQueue"},{"p":"mil.nga.sf.util.sweep","l":"EventType"},{"p":"mil.nga.sf.extended","l":"ExtendedGeometryCollection"},{"p":"mil.nga.sf.util.filter","l":"FiniteFilterType"},{"p":"mil.nga.sf","l":"Geometry"},{"p":"mil.nga.sf","l":"GeometryCollection"},{"p":"mil.nga.sf.util","l":"GeometryConstants"},{"p":"mil.nga.sf","l":"GeometryEnvelope"},{"p":"mil.nga.sf.util","l":"GeometryEnvelopeBuilder"},{"p":"mil.nga.sf.util.filter","l":"GeometryFilter"},{"p":"mil.nga.sf.util","l":"GeometryPrinter"},{"p":"mil.nga.sf","l":"GeometryType"},{"p":"mil.nga.sf.util","l":"GeometryUtils"},{"p":"mil.nga.sf","l":"Line"},{"p":"mil.nga.sf","l":"LinearRing"},{"p":"mil.nga.sf","l":"LineString"},{"p":"mil.nga.sf","l":"MultiCurve"},{"p":"mil.nga.sf","l":"MultiLineString"},{"p":"mil.nga.sf","l":"MultiPoint"},{"p":"mil.nga.sf","l":"MultiPolygon"},{"p":"mil.nga.sf","l":"MultiSurface"},{"p":"mil.nga.sf","l":"Point"},{"p":"mil.nga.sf.util.filter","l":"PointFiniteFilter"},{"p":"mil.nga.sf","l":"Polygon"},{"p":"mil.nga.sf","l":"PolyhedralSurface"},{"p":"mil.nga.sf.util.sweep","l":"Segment"},{"p":"mil.nga.sf.util","l":"SFException"},{"p":"mil.nga.sf.util.sweep","l":"ShamosHoey"},{"p":"mil.nga.sf","l":"Surface"},{"p":"mil.nga.sf.util.sweep","l":"SweepLine"},{"p":"mil.nga.sf.util","l":"TextReader"},{"p":"mil.nga.sf","l":"TIN"},{"p":"mil.nga.sf","l":"Triangle"}] -------------------------------------------------------------------------------- /docs/docs/api/type-search-index.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngageoint/simple-features-java/34f60033d7f843aa429e73959f7ff1f9e593d5ad/docs/docs/api/type-search-index.zip -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Simple Features Java 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 22 | 23 |
24 | 25 |

The Simple Features Java library was developed by the National Geospatial-Intelligence Agency (NGA) in collaboration with BIT Systems. 26 | 27 |

Simple Features is a Java library of geometry objects and utilities based upon the OGC Simple Feature Access standard.

28 | 29 | 39 | 40 |
41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /docs/stylesheets/github-light.css: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2014 GitHub Inc. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | 16 | */ 17 | 18 | .pl-c /* comment */ { 19 | color: #969896; 20 | } 21 | 22 | .pl-c1 /* constant, markup.raw, meta.diff.header, meta.module-reference, meta.property-name, support, support.constant, support.variable, variable.other.constant */, 23 | .pl-s .pl-v /* string variable */ { 24 | color: #0086b3; 25 | } 26 | 27 | .pl-e /* entity */, 28 | .pl-en /* entity.name */ { 29 | color: #795da3; 30 | } 31 | 32 | .pl-s .pl-s1 /* string source */, 33 | .pl-smi /* storage.modifier.import, storage.modifier.package, storage.type.java, variable.other, variable.parameter.function */ { 34 | color: #333; 35 | } 36 | 37 | .pl-ent /* entity.name.tag */ { 38 | color: #63a35c; 39 | } 40 | 41 | .pl-k /* keyword, storage, storage.type */ { 42 | color: #a71d5d; 43 | } 44 | 45 | .pl-pds /* punctuation.definition.string, string.regexp.character-class */, 46 | .pl-s /* string */, 47 | .pl-s .pl-pse .pl-s1 /* string punctuation.section.embedded source */, 48 | .pl-sr /* string.regexp */, 49 | .pl-sr .pl-cce /* string.regexp constant.character.escape */, 50 | .pl-sr .pl-sra /* string.regexp string.regexp.arbitrary-repitition */, 51 | .pl-sr .pl-sre /* string.regexp source.ruby.embedded */ { 52 | color: #183691; 53 | } 54 | 55 | .pl-v /* variable */ { 56 | color: #ed6a43; 57 | } 58 | 59 | .pl-id /* invalid.deprecated */ { 60 | color: #b52a1d; 61 | } 62 | 63 | .pl-ii /* invalid.illegal */ { 64 | background-color: #b52a1d; 65 | color: #f8f8f8; 66 | } 67 | 68 | .pl-sr .pl-cce /* string.regexp constant.character.escape */ { 69 | color: #63a35c; 70 | font-weight: bold; 71 | } 72 | 73 | .pl-ml /* markup.list */ { 74 | color: #693a17; 75 | } 76 | 77 | .pl-mh /* markup.heading */, 78 | .pl-mh .pl-en /* markup.heading entity.name */, 79 | .pl-ms /* meta.separator */ { 80 | color: #1d3e81; 81 | font-weight: bold; 82 | } 83 | 84 | .pl-mq /* markup.quote */ { 85 | color: #008080; 86 | } 87 | 88 | .pl-mi /* markup.italic */ { 89 | color: #333; 90 | font-style: italic; 91 | } 92 | 93 | .pl-mb /* markup.bold */ { 94 | color: #333; 95 | font-weight: bold; 96 | } 97 | 98 | .pl-md /* markup.deleted, meta.diff.header.from-file */ { 99 | background-color: #ffecec; 100 | color: #bd2c00; 101 | } 102 | 103 | .pl-mi1 /* markup.inserted, meta.diff.header.to-file */ { 104 | background-color: #eaffea; 105 | color: #55a532; 106 | } 107 | 108 | .pl-mdr /* meta.diff.range */ { 109 | color: #795da3; 110 | font-weight: bold; 111 | } 112 | 113 | .pl-mo /* meta.output */ { 114 | color: #1d3e81; 115 | } 116 | 117 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | mil.nga 5 | sf 6 | 2.2.3 7 | jar 8 | Simple Features 9 | https://github.com/ngageoint/simple-features-java 10 | Simple Feature Geometries Library 11 | 12 | git@github.com:ngageoint/simple-features-java.git 13 | scm:git:git@github.com:ngageoint/simple-features-java.git 14 | scm:git:git@github.com:ngageoint/simple-features-java.git 15 | 16 | 17 | 18 | The MIT License (MIT) 19 | https://github.com/ngageoint/simple-features-java/blob/master/LICENSE.txt 20 | repo 21 | 22 | 23 | 24 | National Geospatial-Intelligence Agency 25 | https://www.nga.mil/ 26 | 27 | 28 | 29 | bosborn 30 | Brian Osborn 31 | bosborn@caci.com 32 | BIT Systems 33 | https://www.caci.com/bit-systems 34 | 35 | developer 36 | 37 | UTC−07 38 | 39 | 40 | 41 | 11 42 | 11 43 | UTF-8 44 | 45 | 46 | 47 | junit 48 | junit 49 | 4.13.2 50 | test 51 | 52 | 53 | 54 | 55 | 56 | 57 | org.apache.maven.plugins 58 | maven-source-plugin 59 | 3.3.0 60 | 61 | 62 | attach-sources 63 | 64 | jar-no-fork 65 | 66 | 67 | 68 | 69 | 70 | org.apache.maven.plugins 71 | maven-javadoc-plugin 72 | 3.6.3 73 | 74 | 75 | attach-javadocs 76 | 77 | jar 78 | 79 | 80 | -Xdoclint:none 81 | 82 | 83 | 84 | 85 | 86 | org.apache.maven.plugins 87 | maven-gpg-plugin 88 | 3.2.2 89 | 90 | 91 | sign-artifacts 92 | deploy 93 | 94 | sign 95 | 96 | 97 | 98 | 99 | 100 | org.sonatype.plugins 101 | nexus-staging-maven-plugin 102 | 1.6.13 103 | true 104 | 105 | ossrh 106 | https://oss.sonatype.org/ 107 | true 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | ossrh 116 | https://oss.sonatype.org/content/repositories/snapshots 117 | 118 | 119 | ossrh 120 | https://oss.sonatype.org/service/local/staging/deploy/maven2/ 121 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/CircularString.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf; 2 | 3 | import java.util.List; 4 | 5 | import mil.nga.sf.util.GeometryUtils; 6 | 7 | /** 8 | * Circular String, Curve sub type 9 | * 10 | * @author osbornb 11 | */ 12 | public class CircularString extends LineString { 13 | 14 | /** 15 | * Serial Version UID 16 | */ 17 | private static final long serialVersionUID = 1L; 18 | 19 | /** 20 | * Constructor 21 | */ 22 | public CircularString() { 23 | this(false, false); 24 | } 25 | 26 | /** 27 | * Constructor 28 | * 29 | * @param hasZ 30 | * has z 31 | * @param hasM 32 | * has m 33 | */ 34 | public CircularString(boolean hasZ, boolean hasM) { 35 | super(GeometryType.CIRCULARSTRING, hasZ, hasM); 36 | } 37 | 38 | /** 39 | * Constructor 40 | * 41 | * @param points 42 | * list of points 43 | */ 44 | public CircularString(List points) { 45 | this(GeometryUtils.hasZ(points), GeometryUtils.hasM(points)); 46 | setPoints(points); 47 | } 48 | 49 | /** 50 | * Copy Constructor 51 | * 52 | * @param circularString 53 | * circular string to copy 54 | */ 55 | public CircularString(CircularString circularString) { 56 | this(circularString.hasZ(), circularString.hasM()); 57 | for (Point point : circularString.getPoints()) { 58 | addPoint((Point) point.copy()); 59 | } 60 | } 61 | 62 | /** 63 | * {@inheritDoc} 64 | */ 65 | @Override 66 | public Geometry copy() { 67 | return new CircularString(this); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/CompoundCurve.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import mil.nga.sf.util.GeometryUtils; 7 | import mil.nga.sf.util.sweep.ShamosHoey; 8 | 9 | /** 10 | * Compound Curve, Curve sub type 11 | * 12 | * @author osbornb 13 | */ 14 | public class CompoundCurve extends Curve { 15 | 16 | /** 17 | * Serial Version UID 18 | */ 19 | private static final long serialVersionUID = 1L; 20 | 21 | /** 22 | * List of line strings 23 | */ 24 | private List lineStrings = new ArrayList(); 25 | 26 | /** 27 | * Constructor 28 | */ 29 | public CompoundCurve() { 30 | this(false, false); 31 | } 32 | 33 | /** 34 | * Constructor 35 | * 36 | * @param hasZ 37 | * has z 38 | * @param hasM 39 | * has m 40 | */ 41 | public CompoundCurve(boolean hasZ, boolean hasM) { 42 | super(GeometryType.COMPOUNDCURVE, hasZ, hasM); 43 | } 44 | 45 | /** 46 | * Constructor 47 | * 48 | * @param lineStrings 49 | * list of line strings 50 | */ 51 | public CompoundCurve(List lineStrings) { 52 | this(GeometryUtils.hasZ(lineStrings), GeometryUtils.hasM(lineStrings)); 53 | setLineStrings(lineStrings); 54 | } 55 | 56 | /** 57 | * Constructor 58 | * 59 | * @param lineString 60 | * line string 61 | */ 62 | public CompoundCurve(LineString lineString) { 63 | this(lineString.hasZ(), lineString.hasM()); 64 | addLineString(lineString); 65 | } 66 | 67 | /** 68 | * Copy Constructor 69 | * 70 | * @param compoundCurve 71 | * compound Curve to copy 72 | */ 73 | public CompoundCurve(CompoundCurve compoundCurve) { 74 | this(compoundCurve.hasZ(), compoundCurve.hasM()); 75 | for (LineString lineString : compoundCurve.getLineStrings()) { 76 | addLineString((LineString) lineString.copy()); 77 | } 78 | } 79 | 80 | /** 81 | * Get the line strings 82 | * 83 | * @return line strings 84 | */ 85 | public List getLineStrings() { 86 | return lineStrings; 87 | } 88 | 89 | /** 90 | * Set the line strings 91 | * 92 | * @param lineStrings 93 | * line strings 94 | */ 95 | public void setLineStrings(List lineStrings) { 96 | this.lineStrings = lineStrings; 97 | } 98 | 99 | /** 100 | * Add a line string 101 | * 102 | * @param lineString 103 | * line string 104 | */ 105 | public void addLineString(LineString lineString) { 106 | lineStrings.add(lineString); 107 | updateZM(lineString); 108 | } 109 | 110 | /** 111 | * Add line strings 112 | * 113 | * @param lineStrings 114 | * line strings 115 | */ 116 | public void addLineStrings(List lineStrings) { 117 | for (LineString lineString : lineStrings) { 118 | addLineString(lineString); 119 | } 120 | } 121 | 122 | /** 123 | * Get the number of line strings 124 | * 125 | * @return number of line strings 126 | */ 127 | public int numLineStrings() { 128 | return lineStrings.size(); 129 | } 130 | 131 | /** 132 | * Returns the Nth line string 133 | * 134 | * @param n 135 | * nth line string to return 136 | * @return line string 137 | */ 138 | public LineString getLineString(int n) { 139 | return lineStrings.get(n); 140 | } 141 | 142 | /** 143 | * {@inheritDoc} 144 | */ 145 | @Override 146 | public Point startPoint() { 147 | Point startPoint = null; 148 | if (!isEmpty()) { 149 | for (LineString lineString : lineStrings) { 150 | if (!lineString.isEmpty()) { 151 | startPoint = lineString.startPoint(); 152 | break; 153 | } 154 | } 155 | } 156 | return startPoint; 157 | } 158 | 159 | /** 160 | * {@inheritDoc} 161 | */ 162 | @Override 163 | public Point endPoint() { 164 | Point endPoint = null; 165 | if (!isEmpty()) { 166 | for (int i = lineStrings.size() - 1; i >= 0; i--) { 167 | LineString lineString = lineStrings.get(i); 168 | if (!lineString.isEmpty()) { 169 | endPoint = lineString.endPoint(); 170 | break; 171 | } 172 | } 173 | } 174 | return endPoint; 175 | } 176 | 177 | /** 178 | * {@inheritDoc} 179 | */ 180 | @Override 181 | public boolean isSimple() { 182 | return ShamosHoey.simplePolygon(lineStrings); 183 | } 184 | 185 | /** 186 | * {@inheritDoc} 187 | */ 188 | @Override 189 | public Geometry copy() { 190 | return new CompoundCurve(this); 191 | } 192 | 193 | /** 194 | * {@inheritDoc} 195 | */ 196 | @Override 197 | public boolean isEmpty() { 198 | return lineStrings.isEmpty(); 199 | } 200 | 201 | /** 202 | * {@inheritDoc} 203 | */ 204 | @Override 205 | public int hashCode() { 206 | final int prime = 31; 207 | int result = super.hashCode(); 208 | result = prime * result 209 | + ((lineStrings == null) ? 0 : lineStrings.hashCode()); 210 | return result; 211 | } 212 | 213 | /** 214 | * {@inheritDoc} 215 | */ 216 | @Override 217 | public boolean equals(Object obj) { 218 | if (this == obj) 219 | return true; 220 | if (!super.equals(obj)) 221 | return false; 222 | if (getClass() != obj.getClass()) 223 | return false; 224 | CompoundCurve other = (CompoundCurve) obj; 225 | if (lineStrings == null) { 226 | if (other.lineStrings != null) 227 | return false; 228 | } else if (!lineStrings.equals(other.lineStrings)) 229 | return false; 230 | return true; 231 | } 232 | 233 | } 234 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/Curve.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf; 2 | 3 | /** 4 | * The base type for all 1-dimensional geometry types. A 1-dimensional geometry 5 | * is a geometry that has a length, but no area. A curve is considered simple if 6 | * it does not intersect itself (except at the start and end point). A curve is 7 | * considered closed its start and end point are coincident. A simple, closed 8 | * curve is called a ring. 9 | * 10 | * @author osbornb 11 | */ 12 | public abstract class Curve extends Geometry { 13 | 14 | /** 15 | * Serial Version UID 16 | */ 17 | private static final long serialVersionUID = 1L; 18 | 19 | /** 20 | * Constructor 21 | * 22 | * @param type 23 | * geometry type 24 | * @param hasZ 25 | * has z 26 | * @param hasM 27 | * has m 28 | */ 29 | protected Curve(GeometryType type, boolean hasZ, boolean hasM) { 30 | super(type, hasZ, hasM); 31 | } 32 | 33 | /** 34 | * Get the start Point of this Curve 35 | * 36 | * @return start point 37 | */ 38 | public abstract Point startPoint(); 39 | 40 | /** 41 | * Get the end Point of this Curve 42 | * 43 | * @return end point 44 | */ 45 | public abstract Point endPoint(); 46 | 47 | /** 48 | * Determine if this Curve is closed (start point = end point) 49 | * 50 | * @return true if closed 51 | */ 52 | public boolean isClosed() { 53 | return !isEmpty() && startPoint().equals(endPoint()); 54 | } 55 | 56 | /** 57 | * Determine if this Curve is a ring (closed and simple) 58 | * 59 | * @return true if a ring 60 | */ 61 | public boolean isRing() { 62 | return isClosed() && isSimple(); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/CurvePolygon.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import mil.nga.sf.util.GeometryUtils; 7 | 8 | /** 9 | * A planar surface defined by an exterior ring and zero or more interior ring. 10 | * Each ring is defined by a Curve instance. 11 | * 12 | * @author osbornb 13 | * @param 14 | * curve type 15 | */ 16 | public class CurvePolygon extends Surface { 17 | 18 | /** 19 | * Serial Version UID 20 | */ 21 | private static final long serialVersionUID = 1L; 22 | 23 | /** 24 | * List of rings 25 | */ 26 | private List rings = new ArrayList(); 27 | 28 | /** 29 | * Constructor 30 | */ 31 | public CurvePolygon() { 32 | this(false, false); 33 | } 34 | 35 | /** 36 | * Constructor 37 | * 38 | * @param hasZ 39 | * has z 40 | * @param hasM 41 | * has m 42 | */ 43 | public CurvePolygon(boolean hasZ, boolean hasM) { 44 | super(GeometryType.CURVEPOLYGON, hasZ, hasM); 45 | } 46 | 47 | /** 48 | * Constructor 49 | * 50 | * @param rings 51 | * list of rings 52 | */ 53 | public CurvePolygon(List rings) { 54 | this(GeometryUtils.hasZ(rings), GeometryUtils.hasM(rings)); 55 | setRings(rings); 56 | } 57 | 58 | /** 59 | * Constructor 60 | * 61 | * @param ring 62 | * ring 63 | */ 64 | public CurvePolygon(T ring) { 65 | this(ring.hasZ(), ring.hasM()); 66 | addRing(ring); 67 | } 68 | 69 | /** 70 | * Copy Constructor 71 | * 72 | * @param curvePolygon 73 | * curve polygon to copy 74 | */ 75 | public CurvePolygon(CurvePolygon curvePolygon) { 76 | this(curvePolygon.hasZ(), curvePolygon.hasM()); 77 | for (T ring : curvePolygon.getRings()) { 78 | @SuppressWarnings("unchecked") 79 | T ringCopy = (T) ring.copy(); 80 | addRing(ringCopy); 81 | } 82 | } 83 | 84 | /** 85 | * Constructor 86 | * 87 | * @param type 88 | * geometry type 89 | * @param hasZ 90 | * has z 91 | * @param hasM 92 | * has m 93 | */ 94 | protected CurvePolygon(GeometryType type, boolean hasZ, boolean hasM) { 95 | super(type, hasZ, hasM); 96 | } 97 | 98 | /** 99 | * Get the rings 100 | * 101 | * @return rings 102 | */ 103 | public List getRings() { 104 | return rings; 105 | } 106 | 107 | /** 108 | * Set the rings 109 | * 110 | * @param rings 111 | * rings 112 | */ 113 | public void setRings(List rings) { 114 | this.rings = rings; 115 | } 116 | 117 | /** 118 | * Add a ring 119 | * 120 | * @param ring 121 | * ring 122 | */ 123 | public void addRing(T ring) { 124 | rings.add(ring); 125 | updateZM(ring); 126 | } 127 | 128 | /** 129 | * Add rings 130 | * 131 | * @param rings 132 | * rings 133 | */ 134 | public void addRings(List rings) { 135 | for (T ring : rings) { 136 | addRing(ring); 137 | } 138 | } 139 | 140 | /** 141 | * Get the number of rings including exterior and interior 142 | * 143 | * @return number of rings 144 | */ 145 | public int numRings() { 146 | return rings.size(); 147 | } 148 | 149 | /** 150 | * Returns the Nth ring where the exterior ring is at 0, interior rings 151 | * begin at 1 152 | * 153 | * @param n 154 | * nth ring to return 155 | * @return ring 156 | */ 157 | public T getRing(int n) { 158 | return rings.get(n); 159 | } 160 | 161 | /** 162 | * Get the exterior ring 163 | * 164 | * @return exterior ring 165 | */ 166 | public T getExteriorRing() { 167 | return rings.get(0); 168 | } 169 | 170 | /** 171 | * Get the number of interior rings 172 | * 173 | * @return number of interior rings 174 | */ 175 | public int numInteriorRings() { 176 | return rings.size() - 1; 177 | } 178 | 179 | /** 180 | * Returns the Nth interior ring for this Polygon 181 | * 182 | * @param n 183 | * interior ring number 184 | * @return interior ring 185 | */ 186 | public T getInteriorRing(int n) { 187 | return rings.get(n + 1); 188 | } 189 | 190 | /** 191 | * {@inheritDoc} 192 | */ 193 | @Override 194 | public Geometry copy() { 195 | return new CurvePolygon(this); 196 | } 197 | 198 | /** 199 | * {@inheritDoc} 200 | */ 201 | @Override 202 | public boolean isEmpty() { 203 | return rings.isEmpty(); 204 | } 205 | 206 | /** 207 | * {@inheritDoc} 208 | */ 209 | @Override 210 | public boolean isSimple() { 211 | throw new UnsupportedOperationException( 212 | "Is Simple not implemented for " + getClass().getSimpleName()); 213 | } 214 | 215 | /** 216 | * {@inheritDoc} 217 | */ 218 | @Override 219 | public int hashCode() { 220 | final int prime = 31; 221 | int result = super.hashCode(); 222 | result = prime * result + ((rings == null) ? 0 : rings.hashCode()); 223 | return result; 224 | } 225 | 226 | /** 227 | * {@inheritDoc} 228 | */ 229 | @Override 230 | public boolean equals(Object obj) { 231 | if (this == obj) 232 | return true; 233 | if (!super.equals(obj)) 234 | return false; 235 | if (getClass() != obj.getClass()) 236 | return false; 237 | @SuppressWarnings("unchecked") 238 | CurvePolygon other = (CurvePolygon) obj; 239 | if (rings == null) { 240 | if (other.rings != null) 241 | return false; 242 | } else if (!rings.equals(other.rings)) 243 | return false; 244 | return true; 245 | } 246 | 247 | } 248 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/GeometryType.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf; 2 | 3 | import java.util.HashMap; 4 | import java.util.Locale; 5 | import java.util.Map; 6 | 7 | /** 8 | * Geometry Type enumeration 9 | * 10 | * @author osbornb 11 | */ 12 | public enum GeometryType { 13 | 14 | /** 15 | * The root of the geometry type hierarchy 16 | */ 17 | GEOMETRY, 18 | 19 | /** 20 | * A single location in space. Each point has an X and Y coordinate. A point 21 | * MAY optionally also have a Z and/or an M value. 22 | */ 23 | POINT, 24 | 25 | /** 26 | * A Curve that connects two or more points in space. 27 | */ 28 | LINESTRING, 29 | 30 | /** 31 | * A restricted form of CurvePolygon where each ring is defined as a simple, 32 | * closed LineString. 33 | */ 34 | POLYGON, 35 | 36 | /** 37 | * A restricted form of GeometryCollection where each Geometry in the 38 | * collection must be of type Point. 39 | */ 40 | MULTIPOINT, 41 | 42 | /** 43 | * A restricted form of MultiCurve where each Curve in the collection must 44 | * be of type LineString. 45 | */ 46 | MULTILINESTRING, 47 | 48 | /** 49 | * A restricted form of MultiSurface where each Surface in the collection 50 | * must be of type Polygon. 51 | */ 52 | MULTIPOLYGON, 53 | 54 | /** 55 | * A collection of zero or more Geometry instances. 56 | */ 57 | GEOMETRYCOLLECTION, 58 | 59 | /** 60 | * Circular String, Curve sub type 61 | */ 62 | CIRCULARSTRING, 63 | 64 | /** 65 | * Compound Curve, Curve sub type 66 | */ 67 | COMPOUNDCURVE, 68 | 69 | /** 70 | * A planar surface defined by an exterior ring and zero or more interior 71 | * ring. Each ring is defined by a Curve instance. 72 | */ 73 | CURVEPOLYGON, 74 | 75 | /** 76 | * A restricted form of GeometryCollection where each Geometry in the 77 | * collection must be of type Curve. 78 | */ 79 | MULTICURVE, 80 | 81 | /** 82 | * A restricted form of GeometryCollection where each Geometry in the 83 | * collection must be of type Surface. 84 | */ 85 | MULTISURFACE, 86 | 87 | /** 88 | * The base type for all 1-dimensional geometry types. A 1-dimensional 89 | * geometry is a geometry that has a length, but no area. A curve is 90 | * considered simple if it does not intersect itself (except at the start 91 | * and end point). A curve is considered closed its start and end point are 92 | * coincident. A simple, closed curve is called a ring. 93 | */ 94 | CURVE, 95 | 96 | /** 97 | * The base type for all 2-dimensional geometry types. A 2-dimensional 98 | * geometry is a geometry that has an area. 99 | */ 100 | SURFACE, 101 | 102 | /** 103 | * Contiguous collection of polygons which share common boundary segments. 104 | */ 105 | POLYHEDRALSURFACE, 106 | 107 | /** 108 | * A tetrahedron (4 triangular faces), corner at the origin and each unit 109 | * coordinate digit. 110 | */ 111 | TIN, 112 | 113 | /** 114 | * Triangle 115 | */ 116 | TRIANGLE; 117 | 118 | /** 119 | * Name to type mapping for fast find attempts 120 | */ 121 | private static final Map types = new HashMap<>(); 122 | static { 123 | for (GeometryType type : values()) { 124 | types.put(type.name(), type); 125 | } 126 | } 127 | 128 | /** 129 | * Get the name, just use the enum name since they are the same 130 | * 131 | * @return geometry type name 132 | */ 133 | public String getName() { 134 | return name(); 135 | } 136 | 137 | /** 138 | * Get the Geometry Type from the name, ignoring case 139 | * 140 | * @param name 141 | * geometry type name 142 | * @return geometry type 143 | */ 144 | public static GeometryType fromName(String name) { 145 | return valueOf(name.toUpperCase(Locale.US)); 146 | } 147 | 148 | /** 149 | * Find the Geometry Type from the name if it exists, ignoring case 150 | * 151 | * @param name 152 | * name 153 | * @return geometry type or null 154 | * @since 2.0.2 155 | */ 156 | public static GeometryType findName(String name) { 157 | return types.get(name.toUpperCase(Locale.US)); 158 | } 159 | 160 | } 161 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/Line.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf; 2 | 3 | import java.util.List; 4 | 5 | import mil.nga.sf.util.GeometryUtils; 6 | import mil.nga.sf.util.SFException; 7 | 8 | /** 9 | * A LineString with exactly 2 Points. 10 | * 11 | * @author osbornb 12 | */ 13 | public class Line extends LineString { 14 | 15 | /** 16 | * Serial Version UID 17 | */ 18 | private static final long serialVersionUID = 1L; 19 | 20 | /** 21 | * Constructor 22 | */ 23 | public Line() { 24 | this(false, false); 25 | } 26 | 27 | /** 28 | * Constructor 29 | * 30 | * @param hasZ 31 | * has z 32 | * @param hasM 33 | * has m 34 | */ 35 | public Line(boolean hasZ, boolean hasM) { 36 | super(hasZ, hasM); 37 | } 38 | 39 | /** 40 | * Constructor 41 | * 42 | * @param points 43 | * list of points 44 | */ 45 | public Line(List points) { 46 | this(GeometryUtils.hasZ(points), GeometryUtils.hasM(points)); 47 | setPoints(points); 48 | } 49 | 50 | /** 51 | * Constructor 52 | * 53 | * @param point1 54 | * first point 55 | * @param point2 56 | * second point 57 | * @since 2.2.0 58 | */ 59 | public Line(Point point1, Point point2) { 60 | this(point1.hasZ() || point2.hasZ(), point1.hasM() || point2.hasM()); 61 | addPoint(point1); 62 | addPoint(point2); 63 | } 64 | 65 | /** 66 | * Copy Constructor 67 | * 68 | * @param line 69 | * line to copy 70 | */ 71 | public Line(Line line) { 72 | this(line.hasZ(), line.hasM()); 73 | for (Point point : line.getPoints()) { 74 | addPoint((Point) point.copy()); 75 | } 76 | } 77 | 78 | /** 79 | * {@inheritDoc} 80 | */ 81 | @Override 82 | public void setPoints(List points) { 83 | super.setPoints(points); 84 | if (numPoints() != 2) { 85 | throw new SFException("A line must have exactly 2 points."); 86 | } 87 | } 88 | 89 | /** 90 | * {@inheritDoc} 91 | */ 92 | @Override 93 | public Geometry copy() { 94 | return new Line(this); 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/LineString.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import mil.nga.sf.util.GeometryUtils; 7 | import mil.nga.sf.util.sweep.ShamosHoey; 8 | 9 | /** 10 | * A Curve that connects two or more points in space. 11 | * 12 | * @author osbornb 13 | */ 14 | public class LineString extends Curve { 15 | 16 | /** 17 | * Serial Version UID 18 | */ 19 | private static final long serialVersionUID = 1L; 20 | 21 | /** 22 | * List of points 23 | */ 24 | private List points = new ArrayList(); 25 | 26 | /** 27 | * Constructor 28 | */ 29 | public LineString() { 30 | this(false, false); 31 | } 32 | 33 | /** 34 | * Constructor 35 | * 36 | * @param hasZ 37 | * has z 38 | * @param hasM 39 | * has m 40 | */ 41 | public LineString(boolean hasZ, boolean hasM) { 42 | super(GeometryType.LINESTRING, hasZ, hasM); 43 | } 44 | 45 | /** 46 | * Constructor 47 | * 48 | * @param points 49 | * list of points 50 | */ 51 | public LineString(List points) { 52 | this(GeometryUtils.hasZ(points), GeometryUtils.hasM(points)); 53 | setPoints(points); 54 | } 55 | 56 | /** 57 | * Copy Constructor 58 | * 59 | * @param lineString 60 | * line string to copy 61 | */ 62 | public LineString(LineString lineString) { 63 | this(lineString.hasZ(), lineString.hasM()); 64 | for (Point point : lineString.getPoints()) { 65 | addPoint((Point) point.copy()); 66 | } 67 | } 68 | 69 | /** 70 | * Constructor 71 | * 72 | * @param type 73 | * geometry type 74 | * @param hasZ 75 | * has z 76 | * @param hasM 77 | * has m 78 | */ 79 | protected LineString(GeometryType type, boolean hasZ, boolean hasM) { 80 | super(type, hasZ, hasM); 81 | } 82 | 83 | /** 84 | * Get the points 85 | * 86 | * @return points 87 | */ 88 | public List getPoints() { 89 | return points; 90 | } 91 | 92 | /** 93 | * Set the points 94 | * 95 | * @param points 96 | * points 97 | */ 98 | public void setPoints(List points) { 99 | this.points = points; 100 | } 101 | 102 | /** 103 | * Add a point 104 | * 105 | * @param point 106 | * point 107 | */ 108 | public void addPoint(Point point) { 109 | points.add(point); 110 | updateZM(point); 111 | } 112 | 113 | /** 114 | * Add points 115 | * 116 | * @param points 117 | * points 118 | */ 119 | public void addPoints(List points) { 120 | for (Point point : points) { 121 | addPoint(point); 122 | } 123 | } 124 | 125 | /** 126 | * Get the number of points 127 | * 128 | * @return number of points 129 | */ 130 | public int numPoints() { 131 | return points.size(); 132 | } 133 | 134 | /** 135 | * Returns the Nth point 136 | * 137 | * @param n 138 | * nth point to return 139 | * @return point 140 | */ 141 | public Point getPoint(int n) { 142 | return points.get(n); 143 | } 144 | 145 | /** 146 | * {@inheritDoc} 147 | */ 148 | @Override 149 | public Point startPoint() { 150 | Point startPoint = null; 151 | if (!isEmpty()) { 152 | startPoint = points.get(0); 153 | } 154 | return startPoint; 155 | } 156 | 157 | /** 158 | * {@inheritDoc} 159 | */ 160 | @Override 161 | public Point endPoint() { 162 | Point endPoint = null; 163 | if (!isEmpty()) { 164 | endPoint = points.get(points.size() - 1); 165 | } 166 | return endPoint; 167 | } 168 | 169 | /** 170 | * {@inheritDoc} 171 | */ 172 | @Override 173 | public boolean isSimple() { 174 | return ShamosHoey.simplePolygonPoints(points); 175 | } 176 | 177 | /** 178 | * {@inheritDoc} 179 | */ 180 | @Override 181 | public Geometry copy() { 182 | return new LineString(this); 183 | } 184 | 185 | /** 186 | * {@inheritDoc} 187 | */ 188 | @Override 189 | public boolean isEmpty() { 190 | return points.isEmpty(); 191 | } 192 | 193 | /** 194 | * {@inheritDoc} 195 | */ 196 | @Override 197 | public int hashCode() { 198 | final int prime = 31; 199 | int result = super.hashCode(); 200 | result = prime * result + ((points == null) ? 0 : points.hashCode()); 201 | return result; 202 | } 203 | 204 | /** 205 | * {@inheritDoc} 206 | */ 207 | @Override 208 | public boolean equals(Object obj) { 209 | if (this == obj) 210 | return true; 211 | if (!super.equals(obj)) 212 | return false; 213 | if (getClass() != obj.getClass()) 214 | return false; 215 | LineString other = (LineString) obj; 216 | if (points == null) { 217 | if (other.points != null) 218 | return false; 219 | } else if (!points.equals(other.points)) 220 | return false; 221 | return true; 222 | } 223 | 224 | } 225 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/LinearRing.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf; 2 | 3 | import java.util.List; 4 | 5 | import mil.nga.sf.util.GeometryUtils; 6 | import mil.nga.sf.util.SFException; 7 | 8 | /** 9 | * A LineString that is both closed and simple. 10 | * 11 | * @author osbornb 12 | */ 13 | public class LinearRing extends LineString { 14 | 15 | /** 16 | * Serial Version UID 17 | */ 18 | private static final long serialVersionUID = 1L; 19 | 20 | /** 21 | * Constructor 22 | */ 23 | public LinearRing() { 24 | this(false, false); 25 | } 26 | 27 | /** 28 | * Constructor 29 | * 30 | * @param hasZ 31 | * has z 32 | * @param hasM 33 | * has m 34 | */ 35 | public LinearRing(boolean hasZ, boolean hasM) { 36 | super(hasZ, hasM); 37 | } 38 | 39 | /** 40 | * Constructor 41 | * 42 | * @param points 43 | * list of points 44 | */ 45 | public LinearRing(List points) { 46 | this(GeometryUtils.hasZ(points), GeometryUtils.hasM(points)); 47 | setPoints(points); 48 | } 49 | 50 | /** 51 | * Copy Constructor 52 | * 53 | * @param linearRing 54 | * linear ring to copy 55 | */ 56 | public LinearRing(LinearRing linearRing) { 57 | this(linearRing.hasZ(), linearRing.hasM()); 58 | for (Point point : linearRing.getPoints()) { 59 | addPoint((Point) point.copy()); 60 | } 61 | } 62 | 63 | /** 64 | * {@inheritDoc} 65 | */ 66 | @Override 67 | public void setPoints(List points) { 68 | super.setPoints(points); 69 | if (!isEmpty()) { 70 | if (!isClosed()) { 71 | addPoint(points.get(0)); 72 | } 73 | if (numPoints() < 4) { 74 | throw new SFException( 75 | "A closed linear ring must have at least four points."); 76 | } 77 | } 78 | } 79 | 80 | /** 81 | * {@inheritDoc} 82 | */ 83 | @Override 84 | public Geometry copy() { 85 | return new LinearRing(this); 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/MultiCurve.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * A restricted form of GeometryCollection where each Geometry in the collection 7 | * must be of type Curve. 8 | * 9 | * @author osbornb 10 | * @param 11 | * curve type 12 | */ 13 | public abstract class MultiCurve extends GeometryCollection { 14 | 15 | /** 16 | * Serial Version UID 17 | */ 18 | private static final long serialVersionUID = 1L; 19 | 20 | /** 21 | * Constructor 22 | * 23 | * @param type 24 | * geometry type 25 | * @param hasZ 26 | * has z 27 | * @param hasM 28 | * has m 29 | */ 30 | protected MultiCurve(GeometryType type, boolean hasZ, boolean hasM) { 31 | super(type, hasZ, hasM); 32 | } 33 | 34 | /** 35 | * Get the curves 36 | * 37 | * @return curves 38 | */ 39 | public List getCurves() { 40 | return getGeometries(); 41 | } 42 | 43 | /** 44 | * Set the curves 45 | * 46 | * @param curves 47 | * curves 48 | */ 49 | public void setCurves(List curves) { 50 | setGeometries(curves); 51 | } 52 | 53 | /** 54 | * Add a curve 55 | * 56 | * @param curve 57 | * curve 58 | */ 59 | public void addCurve(T curve) { 60 | addGeometry(curve); 61 | } 62 | 63 | /** 64 | * Add curves 65 | * 66 | * @param curves 67 | * curves 68 | */ 69 | public void addCurves(List curves) { 70 | addGeometries(curves); 71 | } 72 | 73 | /** 74 | * Get the number of curves 75 | * 76 | * @return number of curves 77 | */ 78 | public int numCurves() { 79 | return numGeometries(); 80 | } 81 | 82 | /** 83 | * Returns the Nth curve 84 | * 85 | * @param n 86 | * nth line curve to return 87 | * @return curve 88 | */ 89 | public T getCurve(int n) { 90 | return getGeometry(n); 91 | } 92 | 93 | /** 94 | * Determine if this Multi Curve is closed for each Curve (start point = end 95 | * point) 96 | * 97 | * @return true if closed 98 | */ 99 | public boolean isClosed() { 100 | boolean closed = true; 101 | for (Curve curve : getGeometries()) { 102 | if (!curve.isClosed()) { 103 | closed = false; 104 | break; 105 | } 106 | } 107 | return closed; 108 | } 109 | 110 | } 111 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/MultiLineString.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf; 2 | 3 | import java.util.List; 4 | 5 | import mil.nga.sf.util.GeometryUtils; 6 | 7 | /** 8 | * A restricted form of MultiCurve where each Curve in the collection must be of 9 | * type LineString. 10 | * 11 | * @author osbornb 12 | */ 13 | public class MultiLineString extends MultiCurve { 14 | 15 | /** 16 | * Serial Version UID 17 | */ 18 | private static final long serialVersionUID = 1L; 19 | 20 | /** 21 | * Constructor 22 | */ 23 | public MultiLineString() { 24 | this(false, false); 25 | } 26 | 27 | /** 28 | * Constructor 29 | * 30 | * @param hasZ 31 | * has z 32 | * @param hasM 33 | * has m 34 | */ 35 | public MultiLineString(boolean hasZ, boolean hasM) { 36 | super(GeometryType.MULTILINESTRING, hasZ, hasM); 37 | } 38 | 39 | /** 40 | * Constructor 41 | * 42 | * @param lineStrings 43 | * list of line strings 44 | */ 45 | public MultiLineString(List lineStrings) { 46 | this(GeometryUtils.hasZ(lineStrings), GeometryUtils.hasM(lineStrings)); 47 | setLineStrings(lineStrings); 48 | } 49 | 50 | /** 51 | * Constructor 52 | * 53 | * @param lineString 54 | * line string 55 | */ 56 | public MultiLineString(LineString lineString) { 57 | this(lineString.hasZ(), lineString.hasM()); 58 | addLineString(lineString); 59 | } 60 | 61 | /** 62 | * Copy Constructor 63 | * 64 | * @param multiLineString 65 | * multi line string to copy 66 | */ 67 | public MultiLineString(MultiLineString multiLineString) { 68 | this(multiLineString.hasZ(), multiLineString.hasM()); 69 | for (LineString lineString : multiLineString.getLineStrings()) { 70 | addLineString((LineString) lineString.copy()); 71 | } 72 | } 73 | 74 | /** 75 | * Get the line strings 76 | * 77 | * @return line strings 78 | */ 79 | public List getLineStrings() { 80 | return getCurves(); 81 | } 82 | 83 | /** 84 | * Set the line strings 85 | * 86 | * @param lineStrings 87 | * line strings 88 | */ 89 | public void setLineStrings(List lineStrings) { 90 | setCurves(lineStrings); 91 | } 92 | 93 | /** 94 | * Add a line string 95 | * 96 | * @param lineString 97 | * line string 98 | */ 99 | public void addLineString(LineString lineString) { 100 | addCurve(lineString); 101 | } 102 | 103 | /** 104 | * Add line strings 105 | * 106 | * @param lineStrings 107 | * line strings 108 | */ 109 | public void addLineStrings(List lineStrings) { 110 | addCurves(lineStrings); 111 | } 112 | 113 | /** 114 | * Get the number of line strings 115 | * 116 | * @return number of line strings 117 | */ 118 | public int numLineStrings() { 119 | return numCurves(); 120 | } 121 | 122 | /** 123 | * Returns the Nth line string 124 | * 125 | * @param n 126 | * nth line string to return 127 | * @return line string 128 | */ 129 | public LineString getLineString(int n) { 130 | return getCurve(n); 131 | } 132 | 133 | /** 134 | * {@inheritDoc} 135 | */ 136 | @Override 137 | public Geometry copy() { 138 | return new MultiLineString(this); 139 | } 140 | 141 | } 142 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/MultiPoint.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf; 2 | 3 | import java.util.HashSet; 4 | import java.util.List; 5 | import java.util.Set; 6 | 7 | import mil.nga.sf.util.GeometryUtils; 8 | 9 | /** 10 | * A restricted form of GeometryCollection where each Geometry in the collection 11 | * must be of type Point. 12 | * 13 | * @author osbornb 14 | */ 15 | public class MultiPoint extends GeometryCollection { 16 | 17 | /** 18 | * Serial Version UID 19 | */ 20 | private static final long serialVersionUID = 1L; 21 | 22 | /** 23 | * Constructor 24 | */ 25 | public MultiPoint() { 26 | this(false, false); 27 | } 28 | 29 | /** 30 | * Constructor 31 | * 32 | * @param hasZ 33 | * has z 34 | * @param hasM 35 | * has m 36 | */ 37 | public MultiPoint(boolean hasZ, boolean hasM) { 38 | super(GeometryType.MULTIPOINT, hasZ, hasM); 39 | } 40 | 41 | /** 42 | * Constructor 43 | * 44 | * @param points 45 | * list of points 46 | */ 47 | public MultiPoint(List points) { 48 | this(GeometryUtils.hasZ(points), GeometryUtils.hasM(points)); 49 | setPoints(points); 50 | } 51 | 52 | /** 53 | * Constructor 54 | * 55 | * @param point 56 | * point 57 | */ 58 | public MultiPoint(Point point) { 59 | this(point.hasZ(), point.hasM()); 60 | addPoint(point); 61 | } 62 | 63 | /** 64 | * Copy Constructor 65 | * 66 | * @param multiPoint 67 | * multi point to copy 68 | */ 69 | public MultiPoint(MultiPoint multiPoint) { 70 | this(multiPoint.hasZ(), multiPoint.hasM()); 71 | for (Point point : multiPoint.getPoints()) { 72 | addPoint((Point) point.copy()); 73 | } 74 | } 75 | 76 | /** 77 | * Get the points 78 | * 79 | * @return points 80 | */ 81 | public List getPoints() { 82 | return getGeometries(); 83 | } 84 | 85 | /** 86 | * Set the points 87 | * 88 | * @param points 89 | * points 90 | */ 91 | public void setPoints(List points) { 92 | setGeometries(points); 93 | } 94 | 95 | /** 96 | * Add a point 97 | * 98 | * @param point 99 | * point 100 | */ 101 | public void addPoint(Point point) { 102 | addGeometry(point); 103 | } 104 | 105 | /** 106 | * Add points 107 | * 108 | * @param points 109 | * points 110 | */ 111 | public void addPoints(List points) { 112 | addGeometries(points); 113 | } 114 | 115 | /** 116 | * Get the number of points 117 | * 118 | * @return number of points 119 | */ 120 | public int numPoints() { 121 | return numGeometries(); 122 | } 123 | 124 | /** 125 | * Returns the Nth point 126 | * 127 | * @param n 128 | * nth point to return 129 | * @return point 130 | */ 131 | public Point getPoint(int n) { 132 | return getGeometry(n); 133 | } 134 | 135 | /** 136 | * {@inheritDoc} 137 | */ 138 | @Override 139 | public Geometry copy() { 140 | return new MultiPoint(this); 141 | } 142 | 143 | /** 144 | * {@inheritDoc} 145 | */ 146 | @Override 147 | public boolean isSimple() { 148 | Set points = new HashSet<>(getPoints()); 149 | return points.size() == numPoints(); 150 | } 151 | 152 | } 153 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/MultiPolygon.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf; 2 | 3 | import java.util.List; 4 | 5 | import mil.nga.sf.util.GeometryUtils; 6 | 7 | /** 8 | * A restricted form of MultiSurface where each Surface in the collection must 9 | * be of type Polygon. 10 | * 11 | * @author osbornb 12 | */ 13 | public class MultiPolygon extends MultiSurface { 14 | 15 | /** 16 | * Serial Version UID 17 | */ 18 | private static final long serialVersionUID = 1L; 19 | 20 | /** 21 | * Constructor 22 | */ 23 | public MultiPolygon() { 24 | this(false, false); 25 | } 26 | 27 | /** 28 | * Constructor 29 | * 30 | * @param hasZ 31 | * has z 32 | * @param hasM 33 | * has m 34 | */ 35 | public MultiPolygon(boolean hasZ, boolean hasM) { 36 | super(GeometryType.MULTIPOLYGON, hasZ, hasM); 37 | } 38 | 39 | /** 40 | * Constructor 41 | * 42 | * @param polygons 43 | * list of polygons 44 | */ 45 | public MultiPolygon(List polygons) { 46 | this(GeometryUtils.hasZ(polygons), GeometryUtils.hasM(polygons)); 47 | setPolygons(polygons); 48 | } 49 | 50 | /** 51 | * Constructor 52 | * 53 | * @param polygon 54 | * polygon 55 | */ 56 | public MultiPolygon(Polygon polygon) { 57 | this(polygon.hasZ(), polygon.hasM()); 58 | addPolygon(polygon); 59 | } 60 | 61 | /** 62 | * Copy Constructor 63 | * 64 | * @param multiPolygon 65 | * multi polygon to copy 66 | */ 67 | public MultiPolygon(MultiPolygon multiPolygon) { 68 | this(multiPolygon.hasZ(), multiPolygon.hasM()); 69 | for (Polygon polygon : multiPolygon.getPolygons()) { 70 | addPolygon((Polygon) polygon.copy()); 71 | } 72 | } 73 | 74 | /** 75 | * Get the polygons 76 | * 77 | * @return polygons 78 | */ 79 | public List getPolygons() { 80 | return getSurfaces(); 81 | } 82 | 83 | /** 84 | * Set the polygons 85 | * 86 | * @param polygons 87 | * polygons 88 | */ 89 | public void setPolygons(List polygons) { 90 | setSurfaces(polygons); 91 | } 92 | 93 | /** 94 | * Add a polygon 95 | * 96 | * @param polygon 97 | * polygon 98 | */ 99 | public void addPolygon(Polygon polygon) { 100 | addSurface(polygon); 101 | } 102 | 103 | /** 104 | * Add polygons 105 | * 106 | * @param polygons 107 | * polygons 108 | */ 109 | public void addPolygons(List polygons) { 110 | addSurfaces(polygons); 111 | } 112 | 113 | /** 114 | * Get the number of polygons 115 | * 116 | * @return number of polygons 117 | */ 118 | public int numPolygons() { 119 | return numSurfaces(); 120 | } 121 | 122 | /** 123 | * Returns the Nth polygon 124 | * 125 | * @param n 126 | * nth polygon to return 127 | * @return polygon 128 | */ 129 | public Polygon getPolygon(int n) { 130 | return getSurface(n); 131 | } 132 | 133 | /** 134 | * {@inheritDoc} 135 | */ 136 | @Override 137 | public Geometry copy() { 138 | return new MultiPolygon(this); 139 | } 140 | 141 | } 142 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/MultiSurface.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * A restricted form of GeometryCollection where each Geometry in the collection 7 | * must be of type Surface. 8 | * 9 | * @author osbornb 10 | * @param 11 | * surface type 12 | */ 13 | public abstract class MultiSurface extends 14 | GeometryCollection { 15 | 16 | /** 17 | * Serial Version UID 18 | */ 19 | private static final long serialVersionUID = 1L; 20 | 21 | /** 22 | * Constructor 23 | * 24 | * @param type 25 | * geometry type 26 | * @param hasZ 27 | * has z 28 | * @param hasM 29 | * has m 30 | */ 31 | protected MultiSurface(GeometryType type, boolean hasZ, boolean hasM) { 32 | super(type, hasZ, hasM); 33 | } 34 | 35 | /** 36 | * Get the surfaces 37 | * 38 | * @return surfaces 39 | */ 40 | public List getSurfaces() { 41 | return getGeometries(); 42 | } 43 | 44 | /** 45 | * Set the surfaces 46 | * 47 | * @param surfaces 48 | * surfaces 49 | */ 50 | public void setSurfaces(List surfaces) { 51 | setGeometries(surfaces); 52 | } 53 | 54 | /** 55 | * Add a surface 56 | * 57 | * @param surface 58 | * surface 59 | */ 60 | public void addSurface(T surface) { 61 | addGeometry(surface); 62 | } 63 | 64 | /** 65 | * Add surfaces 66 | * 67 | * @param surfaces 68 | * surfaces 69 | */ 70 | public void addSurfaces(List surfaces) { 71 | addGeometries(surfaces); 72 | } 73 | 74 | /** 75 | * Get the number of surfaces 76 | * 77 | * @return number of surfaces 78 | */ 79 | public int numSurfaces() { 80 | return numGeometries(); 81 | } 82 | 83 | /** 84 | * Returns the Nth surface 85 | * 86 | * @param n 87 | * nth line surface to return 88 | * @return surface 89 | */ 90 | public T getSurface(int n) { 91 | return getGeometry(n); 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/Polygon.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf; 2 | 3 | import java.util.List; 4 | 5 | import mil.nga.sf.util.GeometryUtils; 6 | import mil.nga.sf.util.sweep.ShamosHoey; 7 | 8 | /** 9 | * A restricted form of CurvePolygon where each ring is defined as a simple, 10 | * closed LineString. 11 | * 12 | * @author osbornb 13 | */ 14 | public class Polygon extends CurvePolygon { 15 | 16 | /** 17 | * Serial Version UID 18 | */ 19 | private static final long serialVersionUID = 1L; 20 | 21 | /** 22 | * Constructor 23 | */ 24 | public Polygon() { 25 | this(false, false); 26 | } 27 | 28 | /** 29 | * Constructor 30 | * 31 | * @param hasZ 32 | * has z 33 | * @param hasM 34 | * has m 35 | */ 36 | public Polygon(boolean hasZ, boolean hasM) { 37 | super(GeometryType.POLYGON, hasZ, hasM); 38 | } 39 | 40 | /** 41 | * Constructor 42 | * 43 | * @param rings 44 | * list of rings 45 | */ 46 | public Polygon(List rings) { 47 | this(GeometryUtils.hasZ(rings), GeometryUtils.hasM(rings)); 48 | setRings(rings); 49 | } 50 | 51 | /** 52 | * Constructor 53 | * 54 | * @param ring 55 | * ring 56 | */ 57 | public Polygon(LineString ring) { 58 | this(ring.hasZ(), ring.hasM()); 59 | addRing(ring); 60 | } 61 | 62 | /** 63 | * Copy Constructor 64 | * 65 | * @param polygon 66 | * polygon to copy 67 | */ 68 | public Polygon(Polygon polygon) { 69 | this(polygon.hasZ(), polygon.hasM()); 70 | for (LineString ring : polygon.getRings()) { 71 | addRing((LineString) ring.copy()); 72 | } 73 | } 74 | 75 | /** 76 | * Constructor 77 | * 78 | * @param type 79 | * geometry type 80 | * @param hasZ 81 | * has z 82 | * @param hasM 83 | * has m 84 | */ 85 | protected Polygon(GeometryType type, boolean hasZ, boolean hasM) { 86 | super(type, hasZ, hasM); 87 | } 88 | 89 | /** 90 | * {@inheritDoc} 91 | */ 92 | @Override 93 | public Geometry copy() { 94 | return new Polygon(this); 95 | } 96 | 97 | /** 98 | * {@inheritDoc} 99 | */ 100 | @Override 101 | public boolean isSimple() { 102 | return ShamosHoey.simplePolygon(this); 103 | } 104 | 105 | } 106 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/Surface.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf; 2 | 3 | /** 4 | * The base type for all 2-dimensional geometry types. A 2-dimensional geometry 5 | * is a geometry that has an area. 6 | * 7 | * @author osbornb 8 | */ 9 | public abstract class Surface extends Geometry { 10 | 11 | /** 12 | * Serial Version UID 13 | */ 14 | private static final long serialVersionUID = 1L; 15 | 16 | /** 17 | * Constructor 18 | * 19 | * @param type 20 | * geometry type 21 | * @param hasZ 22 | * has z 23 | * @param hasM 24 | * has m 25 | */ 26 | protected Surface(GeometryType type, boolean hasZ, boolean hasM) { 27 | super(type, hasZ, hasM); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/TIN.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf; 2 | 3 | import java.util.List; 4 | 5 | import mil.nga.sf.util.GeometryUtils; 6 | 7 | /** 8 | * A tetrahedron (4 triangular faces), corner at the origin and each unit 9 | * coordinate digit. 10 | * 11 | * @author osbornb 12 | */ 13 | public class TIN extends PolyhedralSurface { 14 | 15 | /** 16 | * Serial Version UID 17 | */ 18 | private static final long serialVersionUID = 1L; 19 | 20 | /** 21 | * Constructor 22 | */ 23 | public TIN() { 24 | this(false, false); 25 | } 26 | 27 | /** 28 | * Constructor 29 | * 30 | * @param hasZ 31 | * has z 32 | * @param hasM 33 | * has m 34 | */ 35 | public TIN(boolean hasZ, boolean hasM) { 36 | super(GeometryType.TIN, hasZ, hasM); 37 | } 38 | 39 | /** 40 | * Constructor 41 | * 42 | * @param polygons 43 | * list of polygons 44 | */ 45 | public TIN(List polygons) { 46 | this(GeometryUtils.hasZ(polygons), GeometryUtils.hasM(polygons)); 47 | setPolygons(polygons); 48 | } 49 | 50 | /** 51 | * Constructor 52 | * 53 | * @param polygon 54 | * polygon 55 | */ 56 | public TIN(Polygon polygon) { 57 | this(polygon.hasZ(), polygon.hasM()); 58 | addPolygon(polygon); 59 | } 60 | 61 | /** 62 | * Copy Constructor 63 | * 64 | * @param tin 65 | * tin to copy 66 | */ 67 | public TIN(TIN tin) { 68 | this(tin.hasZ(), tin.hasM()); 69 | for (Polygon polygon : tin.getPolygons()) { 70 | addPolygon((Polygon) polygon.copy()); 71 | } 72 | } 73 | 74 | /** 75 | * {@inheritDoc} 76 | */ 77 | @Override 78 | public Geometry copy() { 79 | return new TIN(this); 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/Triangle.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf; 2 | 3 | import java.util.List; 4 | 5 | import mil.nga.sf.util.GeometryUtils; 6 | 7 | /** 8 | * Triangle 9 | * 10 | * @author osbornb 11 | */ 12 | public class Triangle extends Polygon { 13 | 14 | /** 15 | * Serial Version UID 16 | */ 17 | private static final long serialVersionUID = 1L; 18 | 19 | /** 20 | * Constructor 21 | */ 22 | public Triangle() { 23 | this(false, false); 24 | } 25 | 26 | /** 27 | * Constructor 28 | * 29 | * @param hasZ 30 | * has z 31 | * @param hasM 32 | * has m 33 | */ 34 | public Triangle(boolean hasZ, boolean hasM) { 35 | super(GeometryType.TRIANGLE, hasZ, hasM); 36 | } 37 | 38 | /** 39 | * Constructor 40 | * 41 | * @param rings 42 | * list of rings 43 | */ 44 | public Triangle(List rings) { 45 | this(GeometryUtils.hasZ(rings), GeometryUtils.hasM(rings)); 46 | setRings(rings); 47 | } 48 | 49 | /** 50 | * Constructor 51 | * 52 | * @param ring 53 | * ring 54 | */ 55 | public Triangle(LineString ring) { 56 | this(ring.hasZ(), ring.hasM()); 57 | addRing(ring); 58 | } 59 | 60 | /** 61 | * Copy Constructor 62 | * 63 | * @param triangle 64 | * triangle to copy 65 | */ 66 | public Triangle(Triangle triangle) { 67 | this(triangle.hasZ(), triangle.hasM()); 68 | for (LineString ring : triangle.getRings()) { 69 | addRing((LineString) ring.copy()); 70 | } 71 | } 72 | 73 | /** 74 | * {@inheritDoc} 75 | */ 76 | @Override 77 | public Geometry copy() { 78 | return new Triangle(this); 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/extended/ExtendedGeometryCollection.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.extended; 2 | 3 | import mil.nga.sf.Geometry; 4 | import mil.nga.sf.GeometryCollection; 5 | import mil.nga.sf.GeometryType; 6 | import mil.nga.sf.util.SFException; 7 | 8 | /** 9 | * Extended Geometry Collection providing abstract geometry collection type 10 | * support 11 | * 12 | * @author osbornb 13 | * 14 | * @param 15 | * geometry type 16 | */ 17 | public class ExtendedGeometryCollection extends 18 | GeometryCollection { 19 | 20 | /** 21 | * Serial Version UID 22 | */ 23 | private static final long serialVersionUID = 1L; 24 | 25 | /** 26 | * Extended geometry collection geometry type 27 | */ 28 | private GeometryType geometryType = GeometryType.GEOMETRYCOLLECTION; 29 | 30 | /** 31 | * Constructor, wraps a geometry collection as extended 32 | * 33 | * @param geometryCollection 34 | * geometry collection 35 | */ 36 | public ExtendedGeometryCollection(GeometryCollection geometryCollection) { 37 | super(GeometryType.GEOMETRYCOLLECTION, geometryCollection.hasZ(), 38 | geometryCollection.hasM()); 39 | setGeometries(geometryCollection.getGeometries()); 40 | updateGeometryType(); 41 | } 42 | 43 | /** 44 | * Copy Constructor 45 | * 46 | * @param extendedGeometryCollection 47 | * extended geometry collection to copy 48 | */ 49 | public ExtendedGeometryCollection( 50 | ExtendedGeometryCollection extendedGeometryCollection) { 51 | super(GeometryType.GEOMETRYCOLLECTION, extendedGeometryCollection 52 | .hasZ(), extendedGeometryCollection.hasM()); 53 | for (T geometry : extendedGeometryCollection.getGeometries()) { 54 | @SuppressWarnings("unchecked") 55 | T geometryCopy = (T) geometry.copy(); 56 | addGeometry(geometryCopy); 57 | } 58 | geometryType = extendedGeometryCollection.getGeometryType(); 59 | } 60 | 61 | /** 62 | * Update the extended geometry type based upon the contained geometries 63 | */ 64 | public void updateGeometryType() { 65 | GeometryType geometryType = getCollectionType(); 66 | switch (geometryType) { 67 | case GEOMETRYCOLLECTION: 68 | case MULTICURVE: 69 | case MULTISURFACE: 70 | break; 71 | case MULTIPOINT: 72 | geometryType = GeometryType.GEOMETRYCOLLECTION; 73 | break; 74 | case MULTILINESTRING: 75 | geometryType = GeometryType.MULTICURVE; 76 | break; 77 | case MULTIPOLYGON: 78 | geometryType = GeometryType.MULTISURFACE; 79 | break; 80 | default: 81 | throw new SFException( 82 | "Unsupported extended geometry collection geometry type: " 83 | + geometryType); 84 | } 85 | this.geometryType = geometryType; 86 | } 87 | 88 | /** 89 | * {@inheritDoc} 90 | */ 91 | @Override 92 | public GeometryType getGeometryType() { 93 | return geometryType; 94 | } 95 | 96 | /** 97 | * {@inheritDoc} 98 | */ 99 | @Override 100 | public Geometry copy() { 101 | return new ExtendedGeometryCollection(this); 102 | } 103 | 104 | /** 105 | * {@inheritDoc} 106 | */ 107 | @Override 108 | public int hashCode() { 109 | final int prime = 31; 110 | int result = super.hashCode(); 111 | result = prime * result 112 | + ((geometryType == null) ? 0 : geometryType.hashCode()); 113 | return result; 114 | } 115 | 116 | /** 117 | * {@inheritDoc} 118 | */ 119 | @Override 120 | public boolean equals(Object obj) { 121 | if (this == obj) 122 | return true; 123 | if (!super.equals(obj)) 124 | return false; 125 | if (getClass() != obj.getClass()) 126 | return false; 127 | @SuppressWarnings("unchecked") 128 | ExtendedGeometryCollection other = (ExtendedGeometryCollection) obj; 129 | if (geometryType != other.geometryType) 130 | return false; 131 | return true; 132 | } 133 | 134 | } 135 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/util/ByteWriter.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.util; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | import java.io.OutputStream; 6 | import java.nio.ByteBuffer; 7 | import java.nio.ByteOrder; 8 | import java.util.logging.Level; 9 | import java.util.logging.Logger; 10 | 11 | /** 12 | * Write a byte array 13 | * 14 | * @author osbornb 15 | */ 16 | public class ByteWriter { 17 | 18 | /** 19 | * Logger 20 | */ 21 | private static final Logger logger = Logger 22 | .getLogger(ByteWriter.class.getName()); 23 | 24 | /** 25 | * Default write byte order 26 | * 27 | * @since 2.0.3 28 | */ 29 | public static final ByteOrder DEFAULT_BYTE_ORDER = ByteOrder.BIG_ENDIAN; 30 | 31 | /** 32 | * Output stream to write bytes to 33 | */ 34 | private final OutputStream outputStream; 35 | 36 | /** 37 | * Byte order 38 | */ 39 | private ByteOrder byteOrder = DEFAULT_BYTE_ORDER; 40 | 41 | /** 42 | * Constructor 43 | */ 44 | public ByteWriter() { 45 | outputStream = new ByteArrayOutputStream(); 46 | } 47 | 48 | /** 49 | * Constructor 50 | * 51 | * @param outputStream 52 | * output stream 53 | * @since 2.0.3 54 | */ 55 | public ByteWriter(OutputStream outputStream) { 56 | this.outputStream = outputStream; 57 | } 58 | 59 | /** 60 | * Constructor 61 | * 62 | * @param byteOrder 63 | * byte order 64 | * @since 2.0.3 65 | */ 66 | public ByteWriter(ByteOrder byteOrder) { 67 | this(); 68 | this.byteOrder = byteOrder; 69 | } 70 | 71 | /** 72 | * Constructor 73 | * 74 | * @param outputStream 75 | * output stream 76 | * @param byteOrder 77 | * byte order 78 | * @since 2.0.3 79 | */ 80 | public ByteWriter(OutputStream outputStream, ByteOrder byteOrder) { 81 | this(outputStream); 82 | this.byteOrder = byteOrder; 83 | } 84 | 85 | /** 86 | * Get the output stream 87 | * 88 | * @return output stream 89 | * @since 2.0.3 90 | */ 91 | public OutputStream getOutputStream() { 92 | return outputStream; 93 | } 94 | 95 | /** 96 | * Get the output stream 97 | * 98 | * @return output stream 99 | * @since 2.0.3 100 | */ 101 | public ByteArrayOutputStream getByteArrayOutputStream() { 102 | if (!(outputStream instanceof ByteArrayOutputStream)) { 103 | throw new SFException( 104 | "Output Stream is not a ByteArrayOutputStream: " 105 | + outputStream.getClass().getName()); 106 | } 107 | return (ByteArrayOutputStream) outputStream; 108 | } 109 | 110 | /** 111 | * Close the byte writer 112 | */ 113 | public void close() { 114 | try { 115 | outputStream.close(); 116 | } catch (IOException e) { 117 | logger.log(Level.WARNING, 118 | "Failed to close byte writer output stream", e); 119 | } 120 | } 121 | 122 | /** 123 | * Get the byte order 124 | * 125 | * @return byte order 126 | */ 127 | public ByteOrder getByteOrder() { 128 | return byteOrder; 129 | } 130 | 131 | /** 132 | * Set the byte order 133 | * 134 | * @param byteOrder 135 | * byte order 136 | */ 137 | public void setByteOrder(ByteOrder byteOrder) { 138 | this.byteOrder = byteOrder; 139 | } 140 | 141 | /** 142 | * Get the written bytes 143 | * 144 | * @return written bytes 145 | */ 146 | public byte[] getBytes() { 147 | return getByteArrayOutputStream().toByteArray(); 148 | } 149 | 150 | /** 151 | * Get the current size in bytes written 152 | * 153 | * @return bytes written 154 | */ 155 | public int size() { 156 | return getByteArrayOutputStream().size(); 157 | } 158 | 159 | /** 160 | * Write a String 161 | * 162 | * @param value 163 | * string value 164 | * @throws IOException 165 | * upon error 166 | */ 167 | public void writeString(String value) throws IOException { 168 | byte[] valueBytes = value.getBytes(); 169 | outputStream.write(valueBytes); 170 | } 171 | 172 | /** 173 | * Write a byte 174 | * 175 | * @param value 176 | * byte 177 | * @throws IOException 178 | * upon error 179 | */ 180 | public void writeByte(byte value) throws IOException { 181 | outputStream.write(value); 182 | } 183 | 184 | /** 185 | * Write an integer 186 | * 187 | * @param value 188 | * int value 189 | * @throws IOException 190 | * upon error 191 | */ 192 | public void writeInt(int value) throws IOException { 193 | byte[] valueBytes = new byte[4]; 194 | ByteBuffer byteBuffer = ByteBuffer.allocate(4).order(byteOrder) 195 | .putInt(value); 196 | byteBuffer.flip(); 197 | byteBuffer.get(valueBytes); 198 | outputStream.write(valueBytes); 199 | } 200 | 201 | /** 202 | * Write a double 203 | * 204 | * @param value 205 | * double 206 | * @throws IOException 207 | * upon error 208 | */ 209 | public void writeDouble(double value) throws IOException { 210 | byte[] valueBytes = new byte[8]; 211 | ByteBuffer byteBuffer = ByteBuffer.allocate(8).order(byteOrder) 212 | .putDouble(value); 213 | byteBuffer.flip(); 214 | byteBuffer.get(valueBytes); 215 | outputStream.write(valueBytes); 216 | } 217 | 218 | } 219 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/util/GeometryConstants.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.util; 2 | 3 | /** 4 | * Geometry Constants 5 | * 6 | * @author osbornb 7 | * @since 2.2.0 8 | */ 9 | public class GeometryConstants { 10 | 11 | /** 12 | * Default epsilon for point in or on line tolerance 13 | */ 14 | public static final double DEFAULT_LINE_EPSILON = 0.000000000000001; 15 | 16 | /** 17 | * Default epsilon for point equality 18 | */ 19 | public static final double DEFAULT_EQUAL_EPSILON = 0.00000001; 20 | 21 | /** 22 | * Web Mercator Latitude Range 23 | */ 24 | public static final double WEB_MERCATOR_MAX_LAT_RANGE = 85.0511287798066; 25 | 26 | /** 27 | * Web Mercator Latitude Range 28 | */ 29 | public static final double WEB_MERCATOR_MIN_LAT_RANGE = -85.05112877980659; 30 | 31 | /** 32 | * Half the world distance in either direction 33 | */ 34 | public static final double WEB_MERCATOR_HALF_WORLD_WIDTH = 20037508.342789244; 35 | 36 | /** 37 | * Half the world longitude width for WGS84 38 | */ 39 | public static final double WGS84_HALF_WORLD_LON_WIDTH = 180.0; 40 | 41 | /** 42 | * Half the world latitude height for WGS84 43 | */ 44 | public static final double WGS84_HALF_WORLD_LAT_HEIGHT = 90.0; 45 | 46 | /** 47 | * Minimum latitude degrees value convertible to meters 48 | */ 49 | public static final double DEGREES_TO_METERS_MIN_LAT = -89.99999999999999; 50 | 51 | /** 52 | * Absolute north bearing in degrees 53 | */ 54 | public static final double BEARING_NORTH = 0.0; 55 | 56 | /** 57 | * Absolute east bearing in degrees 58 | */ 59 | public static final double BEARING_EAST = 90.0; 60 | 61 | /** 62 | * Absolute south bearing in degrees 63 | */ 64 | public static final double BEARING_SOUTH = 180.0; 65 | 66 | /** 67 | * Absolute west bearing degrees 68 | */ 69 | public static final double BEARING_WEST = 270.0; 70 | 71 | /** 72 | * Radians to Degrees conversion 73 | */ 74 | public static final double RADIANS_TO_DEGREES = 180.0 / Math.PI; 75 | 76 | /** 77 | * Degrees to Radians conversion 78 | */ 79 | public static final double DEGREES_TO_RADIANS = Math.PI / 180.0; 80 | 81 | /** 82 | * Earth radius in meters (WGS84) 83 | * 84 | * @since 2.2.2 85 | */ 86 | public static final double EARTH_RADIUS = 6378137.0; 87 | 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/util/SFException.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.util; 2 | 3 | /** 4 | * Simple Features exception 5 | * 6 | * @author osbornb 7 | */ 8 | public class SFException extends RuntimeException { 9 | 10 | /** 11 | * Serial version id 12 | */ 13 | private static final long serialVersionUID = 1L; 14 | 15 | /** 16 | * Constructor 17 | */ 18 | public SFException() { 19 | super(); 20 | } 21 | 22 | /** 23 | * Constructor 24 | * 25 | * @param message 26 | * error message 27 | */ 28 | public SFException(String message) { 29 | super(message); 30 | } 31 | 32 | /** 33 | * Constructor 34 | * 35 | * @param message 36 | * error message 37 | * @param throwable 38 | * throwable 39 | */ 40 | public SFException(String message, Throwable throwable) { 41 | super(message, throwable); 42 | } 43 | 44 | /** 45 | * Constructor 46 | * 47 | * @param throwable 48 | * throwable 49 | */ 50 | public SFException(Throwable throwable) { 51 | super(throwable); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/util/TextReader.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.util; 2 | 3 | import java.io.IOException; 4 | import java.io.Reader; 5 | import java.io.StringReader; 6 | import java.util.logging.Level; 7 | import java.util.logging.Logger; 8 | 9 | /** 10 | * Read through text string 11 | * 12 | * @author osbornb 13 | * @since 2.0.3 14 | */ 15 | public class TextReader { 16 | 17 | /** 18 | * Logger 19 | */ 20 | private static final Logger logger = Logger 21 | .getLogger(TextReader.class.getName()); 22 | 23 | /** 24 | * Reader 25 | */ 26 | private final Reader reader; 27 | 28 | /** 29 | * Next token cache for peeks 30 | */ 31 | private String nextToken; 32 | 33 | /** 34 | * Next character number cache for between token caching 35 | */ 36 | private Integer nextCharacterNum; 37 | 38 | /** 39 | * Constructor 40 | * 41 | * @param text 42 | * text 43 | */ 44 | public TextReader(String text) { 45 | this(new StringReader(text)); 46 | } 47 | 48 | /** 49 | * Constructor 50 | * 51 | * @param reader 52 | * reader 53 | */ 54 | public TextReader(Reader reader) { 55 | this.reader = reader; 56 | } 57 | 58 | /** 59 | * Get the reader 60 | * 61 | * @return reader 62 | */ 63 | public Reader getReader() { 64 | return reader; 65 | } 66 | 67 | /** 68 | * Close the text reader 69 | */ 70 | public void close() { 71 | try { 72 | reader.close(); 73 | } catch (IOException e) { 74 | logger.log(Level.WARNING, "Failed to close text reader", e); 75 | } 76 | } 77 | 78 | /** 79 | * Read the next token. Ignores whitespace until a non whitespace character 80 | * is encountered. Returns a contiguous block of token characters ( [a-z] | 81 | * [A-Z] | [0-9] | - | . | + ) or a non whitespace single character. 82 | * 83 | * @return token 84 | * @throws IOException 85 | * upon read error 86 | */ 87 | public String readToken() throws IOException { 88 | 89 | String token = null; 90 | 91 | // Get the next token, cached or read 92 | if (nextToken != null) { 93 | token = nextToken; 94 | nextToken = null; 95 | } else { 96 | 97 | StringBuilder builder = null; 98 | 99 | // Get the next character, cached or read 100 | int characterNum; 101 | if (nextCharacterNum != null) { 102 | characterNum = nextCharacterNum; 103 | nextCharacterNum = null; 104 | } else { 105 | characterNum = reader.read(); 106 | } 107 | 108 | // Continue while characters are left 109 | while (characterNum != -1) { 110 | 111 | char character = (char) characterNum; 112 | 113 | // Check if not the first character in the token 114 | if (builder != null) { 115 | 116 | // Append token characters 117 | if (isTokenCharacter(character)) { 118 | builder.append(character); 119 | } else { 120 | // Complete the token before this character and cache 121 | // the character 122 | if (!isWhitespace(character)) { 123 | nextCharacterNum = characterNum; 124 | } 125 | break; 126 | } 127 | 128 | } else if (!isWhitespace(character)) { 129 | 130 | // First non whitespace character in the token 131 | builder = new StringBuilder(); 132 | builder.append(character); 133 | 134 | // Complete token if a single character token 135 | if (!isTokenCharacter(character)) { 136 | break; 137 | } 138 | 139 | } 140 | 141 | // Read the next character 142 | characterNum = reader.read(); 143 | } 144 | 145 | if (builder != null) { 146 | token = builder.toString(); 147 | } 148 | 149 | } 150 | return token; 151 | } 152 | 153 | /** 154 | * Peek at the next token without reading past it 155 | * 156 | * @return next token 157 | * @throws IOException 158 | * upon read error 159 | */ 160 | public String peekToken() throws IOException { 161 | if (nextToken == null) { 162 | nextToken = readToken(); 163 | } 164 | return nextToken; 165 | } 166 | 167 | /** 168 | * Read a double 169 | * 170 | * @return double 171 | * @throws IOException 172 | * upon read error 173 | */ 174 | public double readDouble() throws IOException { 175 | String token = readToken(); 176 | if (token == null) { 177 | throw new SFException("Failed to read expected double value"); 178 | } 179 | return Double.parseDouble(token); 180 | } 181 | 182 | /** 183 | * Check if the character is a contiguous block token character: ( [a-z] | 184 | * [A-Z] | [0-9] | - | . | + ) 185 | * 186 | * @param c 187 | * @return 188 | */ 189 | private static boolean isTokenCharacter(char c) { 190 | return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') 191 | || (c >= '0' && c <= '9') || c == '-' || c == '.' || c == '+'; 192 | } 193 | 194 | /** 195 | * Check if the character is whitespace or a space character 196 | * 197 | * @param c 198 | * character 199 | * @return true if whitespace 200 | */ 201 | private static boolean isWhitespace(char c) { 202 | return Character.isWhitespace(c) || Character.isSpaceChar(c); 203 | } 204 | 205 | } 206 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/util/centroid/CentroidCurve.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.util.centroid; 2 | 3 | import java.util.List; 4 | 5 | import mil.nga.sf.CompoundCurve; 6 | import mil.nga.sf.Geometry; 7 | import mil.nga.sf.GeometryCollection; 8 | import mil.nga.sf.GeometryType; 9 | import mil.nga.sf.LineString; 10 | import mil.nga.sf.MultiLineString; 11 | import mil.nga.sf.Point; 12 | import mil.nga.sf.util.GeometryUtils; 13 | import mil.nga.sf.util.SFException; 14 | 15 | /** 16 | * Calculate the centroid from curve based geometries. Implementation based on 17 | * the JTS (Java Topology Suite) CentroidLine. 18 | * 19 | * @author osbornb 20 | * @since 1.0.3 21 | */ 22 | public class CentroidCurve { 23 | 24 | /** 25 | * Sum of curve point locations 26 | */ 27 | private Point sum = new Point(); 28 | 29 | /** 30 | * Total length of curves 31 | */ 32 | private double totalLength = 0; 33 | 34 | /** 35 | * Constructor 36 | */ 37 | public CentroidCurve() { 38 | 39 | } 40 | 41 | /** 42 | * Constructor 43 | * 44 | * @param geometry 45 | * geometry to add 46 | */ 47 | public CentroidCurve(Geometry geometry) { 48 | add(geometry); 49 | } 50 | 51 | /** 52 | * Add a curve based dimension 1 geometry to the centroid total. Ignores 53 | * dimension 0 geometries. 54 | * 55 | * @param geometry 56 | * geometry 57 | */ 58 | public void add(Geometry geometry) { 59 | 60 | GeometryType geometryType = geometry.getGeometryType(); 61 | switch (geometryType) { 62 | case LINESTRING: 63 | case CIRCULARSTRING: 64 | add((LineString) geometry); 65 | break; 66 | case MULTILINESTRING: 67 | MultiLineString multiLineString = (MultiLineString) geometry; 68 | addLineStrings(multiLineString.getLineStrings()); 69 | break; 70 | case COMPOUNDCURVE: 71 | CompoundCurve compoundCurve = (CompoundCurve) geometry; 72 | addLineStrings(compoundCurve.getLineStrings()); 73 | break; 74 | case GEOMETRYCOLLECTION: 75 | case MULTICURVE: 76 | case MULTISURFACE: 77 | @SuppressWarnings("unchecked") 78 | GeometryCollection geomCollection = (GeometryCollection) geometry; 79 | List geometries = geomCollection.getGeometries(); 80 | for (Geometry subGeometry : geometries) { 81 | add(subGeometry); 82 | } 83 | break; 84 | case POINT: 85 | case MULTIPOINT: 86 | // Doesn't contribute to curve dimension 87 | break; 88 | default: 89 | throw new SFException("Unsupported " 90 | + this.getClass().getSimpleName() + " Geometry Type: " 91 | + geometryType); 92 | } 93 | } 94 | 95 | /** 96 | * Add line strings to the centroid total 97 | * 98 | * @param lineStrings 99 | * line strings 100 | */ 101 | private void addLineStrings(List lineStrings) { 102 | for (LineString lineString : lineStrings) { 103 | add(lineString); 104 | } 105 | } 106 | 107 | /** 108 | * Add a line string to the centroid total 109 | * 110 | * @param lineString 111 | * line string 112 | */ 113 | private void add(LineString lineString) { 114 | add(lineString.getPoints()); 115 | } 116 | 117 | /** 118 | * Add points to the centroid total 119 | * 120 | * @param points 121 | * points 122 | */ 123 | private void add(List points) { 124 | for (int i = 0; i < points.size() - 1; i++) { 125 | Point point = points.get(i); 126 | Point nextPoint = points.get(i + 1); 127 | 128 | double length = GeometryUtils.distance(point, nextPoint); 129 | totalLength += length; 130 | 131 | double midX = (point.getX() + nextPoint.getX()) / 2; 132 | sum.setX(sum.getX() + (length * midX)); 133 | double midY = (point.getY() + nextPoint.getY()) / 2; 134 | sum.setY(sum.getY() + (length * midY)); 135 | } 136 | } 137 | 138 | /** 139 | * Get the centroid point 140 | * 141 | * @return centroid point 142 | */ 143 | public Point getCentroid() { 144 | Point centroid = new Point(sum.getX() / totalLength, sum.getY() 145 | / totalLength); 146 | return centroid; 147 | } 148 | 149 | } 150 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/util/centroid/CentroidPoint.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.util.centroid; 2 | 3 | import java.util.List; 4 | 5 | import mil.nga.sf.Geometry; 6 | import mil.nga.sf.GeometryCollection; 7 | import mil.nga.sf.GeometryType; 8 | import mil.nga.sf.MultiPoint; 9 | import mil.nga.sf.Point; 10 | import mil.nga.sf.util.SFException; 11 | 12 | /** 13 | * Calculate the centroid from point based geometries. Implementation based on 14 | * the JTS (Java Topology Suite) CentroidPoint. 15 | * 16 | * @author osbornb 17 | * @since 1.0.3 18 | */ 19 | public class CentroidPoint { 20 | 21 | /** 22 | * Point count 23 | */ 24 | private int count = 0; 25 | 26 | /** 27 | * Sum of point locations 28 | */ 29 | private Point sum = new Point(); 30 | 31 | /** 32 | * Constructor 33 | */ 34 | public CentroidPoint() { 35 | 36 | } 37 | 38 | /** 39 | * Constructor 40 | * 41 | * @param geometry 42 | * geometry to add 43 | */ 44 | public CentroidPoint(Geometry geometry) { 45 | add(geometry); 46 | } 47 | 48 | /** 49 | * Add a point based dimension 0 geometry to the centroid total 50 | * 51 | * @param geometry 52 | * geometry 53 | */ 54 | public void add(Geometry geometry) { 55 | GeometryType geometryType = geometry.getGeometryType(); 56 | switch (geometryType) { 57 | case POINT: 58 | add((Point) geometry); 59 | break; 60 | case MULTIPOINT: 61 | MultiPoint multiPoint = (MultiPoint) geometry; 62 | for (Point point : multiPoint.getPoints()) { 63 | add(point); 64 | } 65 | break; 66 | case GEOMETRYCOLLECTION: 67 | case MULTICURVE: 68 | case MULTISURFACE: 69 | @SuppressWarnings("unchecked") 70 | GeometryCollection geomCollection = (GeometryCollection) geometry; 71 | List geometries = geomCollection.getGeometries(); 72 | for (Geometry subGeometry : geometries) { 73 | add(subGeometry); 74 | } 75 | break; 76 | default: 77 | throw new SFException("Unsupported " 78 | + this.getClass().getSimpleName() + " Geometry Type: " 79 | + geometryType); 80 | } 81 | } 82 | 83 | /** 84 | * Add a point to the centroid total 85 | * 86 | * @param point 87 | * point 88 | */ 89 | private void add(Point point) { 90 | count++; 91 | sum.setX(sum.getX() + point.getX()); 92 | sum.setY(sum.getY() + point.getY()); 93 | } 94 | 95 | /** 96 | * Get the centroid point 97 | * 98 | * @return centroid point 99 | */ 100 | public Point getCentroid() { 101 | Point centroid = new Point(sum.getX() / count, sum.getY() / count); 102 | return centroid; 103 | } 104 | 105 | } 106 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/util/filter/FiniteFilterType.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.util.filter; 2 | 3 | /** 4 | * Finite Filter Type, including finite values and optionally one of either 5 | * infinite or NaN values 6 | * 7 | * @author osbornb 8 | * @since 2.0.3 9 | */ 10 | public enum FiniteFilterType { 11 | 12 | /** 13 | * Accept only finite values 14 | */ 15 | FINITE, 16 | 17 | /** 18 | * Accept finite and infinite values 19 | */ 20 | FINITE_AND_INFINITE, 21 | 22 | /** 23 | * Accept finite and Not a Number values 24 | */ 25 | FINITE_AND_NAN; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/util/filter/GeometryFilter.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.util.filter; 2 | 3 | import mil.nga.sf.Geometry; 4 | import mil.nga.sf.GeometryType; 5 | 6 | /** 7 | * Geometry Filter to filter included geometries and modify them during 8 | * construction 9 | * 10 | * @author osbornb 11 | * @since 2.0.3 12 | */ 13 | public interface GeometryFilter { 14 | 15 | /** 16 | * Filter the geometry 17 | * 18 | * @param containingType 19 | * geometry type of the geometry containing this geometry 20 | * element, null if geometry is top level 21 | * @param geometry 22 | * geometry, may be modified 23 | * @return true if passes filter and geometry should be included 24 | */ 25 | public boolean filter(GeometryType containingType, Geometry geometry); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/util/filter/PointFiniteFilter.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.util.filter; 2 | 3 | import mil.nga.sf.Geometry; 4 | import mil.nga.sf.GeometryType; 5 | import mil.nga.sf.Point; 6 | import mil.nga.sf.util.SFException; 7 | 8 | /** 9 | * Point filter for finite checks on x and y properties, optionally filter on z 10 | * and m properties and non finite values (NaN or infinity) 11 | * 12 | * @author osbornb 13 | * @since 2.0.3 14 | */ 15 | public class PointFiniteFilter implements GeometryFilter { 16 | 17 | /** 18 | * Finite Filter type 19 | */ 20 | private FiniteFilterType type = FiniteFilterType.FINITE; 21 | 22 | /** 23 | * Include z values in filtering 24 | */ 25 | boolean filterZ = false; 26 | 27 | /** 28 | * Include m values in filtering 29 | */ 30 | boolean filterM = false; 31 | 32 | /** 33 | * Default Constructor, filter on x and y, allowing only finite values 34 | */ 35 | public PointFiniteFilter() { 36 | 37 | } 38 | 39 | /** 40 | * Constructor, filter on x and y 41 | * 42 | * @param type 43 | * finite filter type 44 | */ 45 | public PointFiniteFilter(FiniteFilterType type) { 46 | setType(type); 47 | } 48 | 49 | /** 50 | * Constructor, filter on x, y, and optionally z 51 | * 52 | * @param type 53 | * finite filter type 54 | * @param filterZ 55 | * filter z values mode 56 | */ 57 | public PointFiniteFilter(FiniteFilterType type, boolean filterZ) { 58 | setType(type); 59 | setFilterZ(filterZ); 60 | } 61 | 62 | /** 63 | * Constructor, filter on x, y, and optionally z and m 64 | * 65 | * @param type 66 | * finite filter type 67 | * @param filterZ 68 | * filter z values mode 69 | * @param filterM 70 | * filter m values mode 71 | */ 72 | public PointFiniteFilter(FiniteFilterType type, boolean filterZ, 73 | boolean filterM) { 74 | setType(type); 75 | setFilterZ(filterZ); 76 | setFilterM(filterM); 77 | } 78 | 79 | /** 80 | * Constructor, filter on x, y, and optionally z 81 | * 82 | * @param filterZ 83 | * filter z values mode 84 | */ 85 | public PointFiniteFilter(boolean filterZ) { 86 | setFilterZ(filterZ); 87 | } 88 | 89 | /** 90 | * Constructor, filter on x, y, and optionally z and m 91 | * 92 | * @param filterZ 93 | * filter z values mode 94 | * @param filterM 95 | * filter m values mode 96 | */ 97 | public PointFiniteFilter(boolean filterZ, boolean filterM) { 98 | setFilterZ(filterZ); 99 | setFilterM(filterM); 100 | } 101 | 102 | /** 103 | * Get the finite filter type 104 | * 105 | * @return finite filter type 106 | */ 107 | public FiniteFilterType getType() { 108 | return type; 109 | } 110 | 111 | /** 112 | * Set the finite filter type, null defaults to 113 | * {@link FiniteFilterType#FINITE} 114 | * 115 | * @param type 116 | * finite filter type 117 | */ 118 | public void setType(FiniteFilterType type) { 119 | this.type = type; 120 | } 121 | 122 | /** 123 | * Is filtering for z values enabled? 124 | * 125 | * @return true if z filtering 126 | */ 127 | public boolean isFilterZ() { 128 | return filterZ; 129 | } 130 | 131 | /** 132 | * Set the z value filtering mode 133 | * 134 | * @param filterZ 135 | * true to z filter 136 | */ 137 | public void setFilterZ(boolean filterZ) { 138 | this.filterZ = filterZ; 139 | } 140 | 141 | /** 142 | * Is filtering for m values enabled? 143 | * 144 | * @return true if m filtering 145 | */ 146 | public boolean isFilterM() { 147 | return filterM; 148 | } 149 | 150 | /** 151 | * Set the m value filtering mode 152 | * 153 | * @param filterM 154 | * true to m filter 155 | */ 156 | public void setFilterM(boolean filterM) { 157 | this.filterM = filterM; 158 | } 159 | 160 | /** 161 | * {@inheritDoc} 162 | */ 163 | @Override 164 | public boolean filter(GeometryType containingType, Geometry geometry) { 165 | return geometry.getGeometryType() != GeometryType.POINT 166 | || !(geometry instanceof Point) || filter((Point) geometry); 167 | } 168 | 169 | /** 170 | * Filter the point 171 | * 172 | * @param point 173 | * point 174 | * @return true if passes filter and point should be included 175 | */ 176 | private boolean filter(Point point) { 177 | return filter(point.getX()) && filter(point.getY()) && filterZ(point) 178 | && filterM(point); 179 | } 180 | 181 | /** 182 | * Filter the double value 183 | * 184 | * @param value 185 | * double value 186 | * @return 187 | */ 188 | private boolean filter(double value) { 189 | boolean passes; 190 | switch (type) { 191 | case FINITE: 192 | passes = Double.isFinite(value); 193 | break; 194 | case FINITE_AND_INFINITE: 195 | passes = !Double.isNaN(value); 196 | break; 197 | case FINITE_AND_NAN: 198 | passes = !Double.isInfinite(value); 199 | break; 200 | default: 201 | throw new SFException("Unsupported filter type: " + type); 202 | } 203 | return passes; 204 | } 205 | 206 | /** 207 | * Filter the Z value 208 | * 209 | * @param point 210 | * point 211 | * @return true if passes 212 | */ 213 | private boolean filterZ(Point point) { 214 | return !filterZ || !point.hasZ() || filter(point.getZ()); 215 | } 216 | 217 | /** 218 | * Filter the M value 219 | * 220 | * @param point 221 | * point 222 | * @return true if passes 223 | */ 224 | private boolean filterM(Point point) { 225 | return !filterM || !point.hasM() || filter(point.getM()); 226 | } 227 | 228 | /** 229 | * Filter the Double value 230 | * 231 | * @param value 232 | * Double value 233 | * @return true if passes 234 | */ 235 | private boolean filter(Double value) { 236 | return value == null || filter(value.doubleValue()); 237 | } 238 | 239 | } 240 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/util/sweep/Event.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.util.sweep; 2 | 3 | import mil.nga.sf.Point; 4 | 5 | /** 6 | * Event element 7 | * 8 | * @author osbornb 9 | * @since 1.0.5 10 | */ 11 | public class Event implements Comparable { 12 | 13 | /** 14 | * Edge number 15 | */ 16 | private int edge; 17 | 18 | /** 19 | * Polygon ring number 20 | */ 21 | private int ring; 22 | 23 | /** 24 | * Polygon point 25 | */ 26 | private Point point; 27 | 28 | /** 29 | * Event type, left or right point 30 | */ 31 | private EventType type; 32 | 33 | /** 34 | * Constructor 35 | * 36 | * @param edge 37 | * edge number 38 | * @param ring 39 | * ring number 40 | * @param point 41 | * point 42 | * @param type 43 | * event type 44 | */ 45 | public Event(int edge, int ring, Point point, EventType type) { 46 | this.edge = edge; 47 | this.ring = ring; 48 | this.point = point; 49 | this.type = type; 50 | } 51 | 52 | /** 53 | * Get the edge 54 | * 55 | * @return edge number 56 | */ 57 | public int getEdge() { 58 | return edge; 59 | } 60 | 61 | /** 62 | * Get the polygon ring number 63 | * 64 | * @return polygon ring number 65 | */ 66 | public int getRing() { 67 | return ring; 68 | } 69 | 70 | /** 71 | * Get the polygon point 72 | * 73 | * @return polygon point 74 | */ 75 | public Point getPoint() { 76 | return point; 77 | } 78 | 79 | /** 80 | * Get the event type 81 | * 82 | * @return event type 83 | */ 84 | public EventType getType() { 85 | return type; 86 | } 87 | 88 | /** 89 | * {@inheritDoc} 90 | */ 91 | @Override 92 | public int compareTo(Event other) { 93 | return SweepLine.xyOrder(point, other.point); 94 | } 95 | 96 | } -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/util/sweep/EventQueue.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.util.sweep; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.Iterator; 6 | import java.util.List; 7 | 8 | import mil.nga.sf.LineString; 9 | import mil.nga.sf.Point; 10 | 11 | /** 12 | * Event queue for processing events 13 | * 14 | * @author osbornb 15 | * @since 1.0.5 16 | */ 17 | public class EventQueue implements Iterable { 18 | 19 | /** 20 | * List of events 21 | */ 22 | private List events = new ArrayList<>(); 23 | 24 | /** 25 | * Constructor 26 | * 27 | * @param ring 28 | * polygon ring 29 | */ 30 | public EventQueue(LineString ring) { 31 | addRing(ring, 0); 32 | sort(); 33 | } 34 | 35 | /** 36 | * Constructor 37 | * 38 | * @param rings 39 | * polygon rings 40 | */ 41 | public EventQueue(List rings) { 42 | for (int i = 0; i < rings.size(); i++) { 43 | LineString ring = rings.get(i); 44 | addRing(ring, i); 45 | } 46 | sort(); 47 | } 48 | 49 | /** 50 | * Add a ring to the event queue 51 | * 52 | * @param ring 53 | * polygon ring 54 | * @param ringIndex 55 | * ring index 56 | */ 57 | private void addRing(LineString ring, int ringIndex) { 58 | 59 | List points = ring.getPoints(); 60 | 61 | for (int i = 0; i < points.size(); i++) { 62 | 63 | Point point1 = points.get(i); 64 | Point point2 = points.get((i + 1) % points.size()); 65 | 66 | EventType type1 = null; 67 | EventType type2 = null; 68 | if (SweepLine.xyOrder(point1, point2) < 0) { 69 | type1 = EventType.LEFT; 70 | type2 = EventType.RIGHT; 71 | } else { 72 | type1 = EventType.RIGHT; 73 | type2 = EventType.LEFT; 74 | } 75 | 76 | Event endpoint1 = new Event(i, ringIndex, point1, type1); 77 | Event endpoint2 = new Event(i, ringIndex, point2, type2); 78 | 79 | events.add(endpoint1); 80 | events.add(endpoint2); 81 | } 82 | } 83 | 84 | /** 85 | * Sort the events 86 | */ 87 | private void sort() { 88 | Collections.sort(events); 89 | } 90 | 91 | /** 92 | * {@inheritDoc} 93 | */ 94 | @Override 95 | public Iterator iterator() { 96 | return events.iterator(); 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/util/sweep/EventType.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.util.sweep; 2 | 3 | /** 4 | * Event type of the point direction 5 | * 6 | * @author osbornb 7 | * @since 1.0.5 8 | */ 9 | public enum EventType { 10 | 11 | /** 12 | * Left point 13 | */ 14 | LEFT, 15 | 16 | /** 17 | * Right point 18 | */ 19 | RIGHT; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/util/sweep/Segment.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.util.sweep; 2 | 3 | import mil.nga.sf.Point; 4 | 5 | /** 6 | * Line segment of an edge between two points 7 | * 8 | * @author osbornb 9 | * @since 1.0.5 10 | */ 11 | public class Segment { 12 | 13 | /** 14 | * Edge number 15 | */ 16 | private int edge; 17 | 18 | /** 19 | * Polygon ring number 20 | */ 21 | private int ring; 22 | 23 | /** 24 | * Left point 25 | */ 26 | private Point leftPoint; 27 | 28 | /** 29 | * Right point 30 | */ 31 | private Point rightPoint; 32 | 33 | /** 34 | * Segment above 35 | */ 36 | private Segment above; 37 | 38 | /** 39 | * Segment below 40 | */ 41 | private Segment below; 42 | 43 | /** 44 | * Constructor 45 | * 46 | * @param edge 47 | * edge number 48 | * @param ring 49 | * ring number 50 | * @param leftPoint 51 | * left point 52 | * @param rightPoint 53 | * right point 54 | */ 55 | public Segment(int edge, int ring, Point leftPoint, Point rightPoint) { 56 | this.edge = edge; 57 | this.ring = ring; 58 | this.leftPoint = leftPoint; 59 | this.rightPoint = rightPoint; 60 | } 61 | 62 | /** 63 | * Get the edge number 64 | * 65 | * @return edge number 66 | */ 67 | public int getEdge() { 68 | return edge; 69 | } 70 | 71 | /** 72 | * Get the polygon ring number 73 | * 74 | * @return polygon ring number 75 | */ 76 | public int getRing() { 77 | return ring; 78 | } 79 | 80 | /** 81 | * Get the left point 82 | * 83 | * @return left point 84 | */ 85 | public Point getLeftPoint() { 86 | return leftPoint; 87 | } 88 | 89 | /** 90 | * Get the right point 91 | * 92 | * @return right point 93 | */ 94 | public Point getRightPoint() { 95 | return rightPoint; 96 | } 97 | 98 | /** 99 | * Get the segment above 100 | * 101 | * @return segment above 102 | */ 103 | public Segment getAbove() { 104 | return above; 105 | } 106 | 107 | /** 108 | * Set the segment above 109 | * 110 | * @param above 111 | * segment above 112 | */ 113 | public void setAbove(Segment above) { 114 | this.above = above; 115 | } 116 | 117 | /** 118 | * Get the segment below 119 | * 120 | * @return segment below 121 | */ 122 | public Segment getBelow() { 123 | return below; 124 | } 125 | 126 | /** 127 | * Set the segment below 128 | * 129 | * @param below 130 | * segment below 131 | */ 132 | public void setBelow(Segment below) { 133 | this.below = below; 134 | } 135 | 136 | } 137 | -------------------------------------------------------------------------------- /src/test/java/mil/nga/sf/GeometrySerializableTest.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf; 2 | 3 | import java.io.IOException; 4 | 5 | import org.junit.Test; 6 | 7 | import mil.nga.sf.util.GeometryUtils; 8 | 9 | /** 10 | * Geometry Collection tests 11 | * 12 | * @author osbornb 13 | */ 14 | public class GeometrySerializableTest { 15 | 16 | @Test 17 | public void testPolygon() throws ClassNotFoundException, IOException { 18 | 19 | testSerializable(SFTestUtils.createPolygon(Math.random() < .5, 20 | Math.random() < .5)); 21 | 22 | } 23 | 24 | @Test 25 | public void testLineString() throws ClassNotFoundException, IOException { 26 | 27 | testSerializable(SFTestUtils.createLineString(Math.random() < .5, 28 | Math.random() < .5)); 29 | 30 | } 31 | 32 | @Test 33 | public void testPoint() throws ClassNotFoundException, IOException { 34 | 35 | testSerializable(SFTestUtils.createPoint(Math.random() < .5, 36 | Math.random() < .5)); 37 | 38 | } 39 | 40 | @Test 41 | public void testGeometryCollection() 42 | throws ClassNotFoundException, IOException { 43 | 44 | testSerializable(SFTestUtils.createGeometryCollection( 45 | Math.random() < .5, Math.random() < .5)); 46 | 47 | } 48 | 49 | @Test 50 | public void testMultiPolygon() throws ClassNotFoundException, IOException { 51 | 52 | testSerializable(SFTestUtils.createMultiPolygon(Math.random() < .5, 53 | Math.random() < .5)); 54 | 55 | } 56 | 57 | @Test 58 | public void testMultiLineString() 59 | throws ClassNotFoundException, IOException { 60 | 61 | testSerializable(SFTestUtils.createMultiLineString(Math.random() < .5, 62 | Math.random() < .5)); 63 | 64 | } 65 | 66 | @Test 67 | public void testMultiPoint() throws ClassNotFoundException, IOException { 68 | 69 | testSerializable(SFTestUtils.createMultiPoint(Math.random() < .5, 70 | Math.random() < .5)); 71 | 72 | } 73 | 74 | @Test 75 | public void testCurvePolygon() throws ClassNotFoundException, IOException { 76 | 77 | testSerializable(SFTestUtils.createCurvePolygon(Math.random() < .5, 78 | Math.random() < .5)); 79 | 80 | } 81 | 82 | @Test 83 | public void testCompoundCurve() throws ClassNotFoundException, IOException { 84 | 85 | testSerializable(SFTestUtils.createCompoundCurve(Math.random() < .5, 86 | Math.random() < .5)); 87 | 88 | } 89 | 90 | private void testSerializable(Geometry geometry) 91 | throws IOException, ClassNotFoundException { 92 | 93 | byte[] bytes = GeometryUtils.serialize(geometry); 94 | Geometry deserializedGeometry = GeometryUtils.deserialize(bytes); 95 | 96 | SFTestUtils.compareGeometries(geometry, deserializedGeometry); 97 | 98 | } 99 | 100 | } 101 | --------------------------------------------------------------------------------