├── .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 │ │ │ └── geojson │ │ │ ├── Feature.html │ │ │ ├── FeatureCollection.html │ │ │ ├── FeatureConverter.html │ │ │ ├── GeoJsonObject.html │ │ │ ├── Geometry.html │ │ │ ├── GeometryCollection.html │ │ │ ├── GeometryType.html │ │ │ ├── LineString.html │ │ │ ├── MultiLineString.html │ │ │ ├── MultiPoint.html │ │ │ ├── MultiPolygon.html │ │ │ ├── Point.html │ │ │ ├── Polygon.html │ │ │ ├── Position.html │ │ │ ├── class-use │ │ │ ├── Feature.html │ │ │ ├── FeatureCollection.html │ │ │ ├── FeatureConverter.html │ │ │ ├── GeoJsonObject.html │ │ │ ├── Geometry.html │ │ │ ├── GeometryCollection.html │ │ │ ├── GeometryType.html │ │ │ ├── LineString.html │ │ │ ├── MultiLineString.html │ │ │ ├── MultiPoint.html │ │ │ ├── MultiPolygon.html │ │ │ ├── Point.html │ │ │ ├── Polygon.html │ │ │ └── Position.html │ │ │ ├── jackson │ │ │ ├── CoordinatesDeserializer.html │ │ │ ├── CoordinatesSerializer.html │ │ │ ├── class-use │ │ │ │ ├── CoordinatesDeserializer.html │ │ │ │ └── CoordinatesSerializer.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ └── package-use.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 │ └── geojson │ ├── Feature.java │ ├── FeatureCollection.java │ ├── FeatureConverter.java │ ├── GeoJsonObject.java │ ├── Geometry.java │ ├── GeometryCollection.java │ ├── GeometryType.java │ ├── LineString.java │ ├── MultiLineString.java │ ├── MultiPoint.java │ ├── MultiPolygon.java │ ├── Point.java │ ├── Polygon.java │ ├── Position.java │ └── jackson │ ├── CoordinatesDeserializer.java │ └── CoordinatesSerializer.java └── test ├── java └── mil │ └── nga │ └── sf │ └── geojson │ ├── FeatureCollectionTest.java │ ├── FeatureTest.java │ ├── GeometryCollectionTest.java │ ├── LineStringTest.java │ ├── MultiLineStringTest.java │ ├── MultiPointTest.java │ ├── MultiPolygonTest.java │ ├── PointTest.java │ ├── PolygonTest.java │ ├── ReadmeTest.java │ └── TestUtils.java └── resources ├── fc-points-altitude.geojson ├── fc-points.geojson ├── gc-multiple.geojson └── gc.geojson /.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 GeoJSON Java Version: 15 | * SF GeoJSON 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-geojson-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-geojson 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: Determine Simple Features Repository 16 | uses: frabert/replace-string-action@master 17 | id: sf-repository 18 | with: 19 | pattern: 'geojson-' 20 | string: "${{ github.repository }}" 21 | replace-with: '' 22 | - name: Checkout Simple Features Repository 23 | uses: actions/checkout@v3 24 | with: 25 | repository: ${{ steps.sf-repository.outputs.replaced }} 26 | ref: ${{ github.ref }} 27 | path: simple-features-java 28 | - name: set up JDK 11 29 | uses: actions/setup-java@v3 30 | with: 31 | distribution: 'temurin' 32 | java-version: 11 33 | - name: Build & Install Simple Features 34 | run: mvn -f simple-features-java clean install -DskipTests 35 | - name: Checkout Repository 36 | uses: actions/checkout@v3 37 | - name: Build 38 | run: mvn clean package -DskipTests 39 | -------------------------------------------------------------------------------- /.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 | ## 3.3.4 (TBD) 8 | 9 | * TBD 10 | 11 | ## [3.3.3](https://github.com/ngageoint/simple-features-geojson-java/releases/tag/3.3.3) (04-03-2024) 12 | 13 | * simple-features-java version 2.2.2 14 | * GeoJsonObject simple geometry retrieval method 15 | * FeatureConverter conversion to simple geometry utility methods 16 | * jackson-databind version 2.17.0 17 | 18 | ## [3.3.2](https://github.com/ngageoint/simple-features-geojson-java/releases/tag/3.3.2) (01-19-2023) 19 | 20 | * simple-features-java version 2.2.1 21 | 22 | ## [3.3.1](https://github.com/ngageoint/simple-features-geojson-java/releases/tag/3.3.1) (12-07-2022) 23 | 24 | * jackson-databind version 2.14.1 25 | 26 | ## [3.3.0](https://github.com/ngageoint/simple-features-geojson-java/releases/tag/3.3.0) (10-03-2022) 27 | 28 | * GeoJsonObject hierarchy (Geometries and Features) equals and hashCode implementations 29 | 30 | ## [3.2.0](https://github.com/ngageoint/simple-features-geojson-java/releases/tag/3.2.0) (09-21-2022) 31 | 32 | * simple-features-java version 2.2.0 33 | * jackson-databind 2.13.4 34 | 35 | ## [3.1.0](https://github.com/ngageoint/simple-features-geojson-java/releases/tag/3.1.0) (07-11-2022) 36 | 37 | * simple-features-java version 2.1.0 38 | * jackson-databind 2.13.3 39 | 40 | ## [3.0.2](https://github.com/ngageoint/simple-features-geojson-java/releases/tag/3.0.2) (04-18-2022) 41 | 42 | * simple-features-java version 2.0.6 43 | * jackson-databind version 2.13.2.2 44 | 45 | ## [3.0.1](https://github.com/ngageoint/simple-features-geojson-java/releases/tag/3.0.1) (02-03-2022) 46 | 47 | * simple-features-java version 2.0.5 48 | * jackson-databind version 2.13.1 49 | * Java 11 50 | 51 | ## [3.0.0](https://github.com/ngageoint/simple-features-geojson-java/releases/tag/3.0.0) (11-01-2021) 52 | 53 | * GeoJSON backed Geometries and Features 54 | * Additional Position element value support when not converting to base simple features 55 | * GeoJSON GeometryType 56 | * Simple Feature Geometry getters and setters 57 | * Feature empty "properties" member inclusion 58 | * jackson-databind version 2.13.0 59 | 60 | ## [2.0.5](https://github.com/ngageoint/simple-features-geojson-java/releases/tag/2.0.5) (03-03-2021) 61 | 62 | * simple-features-java version 2.0.4 63 | * jackson-databind version 2.12.1 64 | 65 | ## [2.0.4](https://github.com/ngageoint/simple-features-geojson-java/releases/tag/2.0.4) (07-13-2020) 66 | 67 | * simple-features-java version 2.0.3 68 | * jackson-databind version 2.11.1 69 | 70 | ## [2.0.3](https://github.com/ngageoint/simple-features-geojson-java/releases/tag/2.0.3) (11-14-2019) 71 | 72 | * jackson-databind version 2.10.1 73 | 74 | ## [2.0.2](https://github.com/ngageoint/simple-features-geojson-java/releases/tag/2.0.2) (07-08-2019) 75 | 76 | * simple-features-java version 2.0.2 77 | * jackson-databind version 2.9.9 78 | * bbox support 79 | * Optional properties 80 | * Allow unknown properties as foreign members 81 | * Generic object support in FeatureConverter 82 | * Non empty inclusions by default 83 | * Crs removed 84 | 85 | ## [2.0.1](https://github.com/ngageoint/simple-features-geojson-java/releases/tag/2.0.1) (04-01-2019) 86 | 87 | * simple-features-java version 2.0.1 88 | * jackson-databind version 2.9.8 89 | * Eclipse project cleanup 90 | 91 | ## [2.0.0](https://github.com/ngageoint/simple-features-geojson-java/releases/tag/2.0.0) (05-17-2018) 92 | 93 | * Initial Release 94 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018 National Geospatial-Intelligence Agency 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 GeoJSON Java 2 | 3 | #### Simple Features GeoJSON 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 GeoJSON](http://ngageoint.github.io/simple-features-geojson-java/) is a Java library for writing and reading [Simple Feature](https://github.com/ngageoint/simple-features-java) Geometries to and from GeoJSON. 15 | 16 | ### Usage ### 17 | 18 | View the latest [Javadoc](http://ngageoint.github.io/simple-features-geojson-java/docs/api/) 19 | 20 | #### Read #### 21 | 22 | ```java 23 | 24 | //String content = ... 25 | 26 | Geometry geometry = FeatureConverter.toGeometry(content); 27 | mil.nga.sf.Geometry simpleGeometry = geometry.getGeometry(); 28 | 29 | /* Read as a generic GeoJSON object, Feature, or Feature Collection */ 30 | //GeoJsonObject geoJsonObject = FeatureConverter.toGeoJsonObject(content); 31 | //Feature feature = FeatureConverter.toFeature(content); 32 | //FeatureCollection featureCollection = FeatureConverter.toFeatureCollection(content); 33 | 34 | ``` 35 | 36 | #### Write #### 37 | 38 | ```java 39 | 40 | //Geometry geometry = ... 41 | 42 | String content = FeatureConverter.toStringValue(geometry); 43 | 44 | Feature feature = FeatureConverter.toFeature(geometry); 45 | String featureContent = FeatureConverter.toStringValue(feature); 46 | 47 | FeatureCollection featureCollection = FeatureConverter.toFeatureCollection(geometry); 48 | String featureCollectionContent = FeatureConverter.toStringValue(featureCollection); 49 | 50 | Map contentMap = FeatureConverter.toMap(geometry); 51 | 52 | ``` 53 | 54 | ### Installation ### 55 | 56 | Pull from the [Maven Central Repository](http://search.maven.org/#artifactdetails|mil.nga.sf|sf-geojson|3.3.3|jar) (JAR, POM, Source, Javadoc) 57 | 58 | ```xml 59 | 60 | 61 | mil.nga.sf 62 | sf-geojson 63 | 3.3.3 64 | 65 | 66 | ``` 67 | 68 | ### Build ### 69 | 70 | [![Build & Test](https://github.com/ngageoint/simple-features-geojson-java/workflows/Build%20&%20Test/badge.svg)](https://github.com/ngageoint/simple-features-geojson-java/actions/workflows/build-test.yml) 71 | 72 | Build this repository using Eclipse and/or Maven: 73 | 74 | mvn clean install 75 | 76 | ### Remote Dependencies ### 77 | 78 | * [Simple Features](https://github.com/ngageoint/simple-features-java) (The MIT License (MIT)) - Simple Features Lib 79 | * [Jackson Data Processor](https://github.com/FasterXML/jackson-databind) (Apache License, Version 2.0) - Jackson data-binding functionality and tree-model 80 | -------------------------------------------------------------------------------- /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 GeoJSON 3.3.3 API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 |

All Classes

22 |
23 | 41 |
42 | 43 | 44 | -------------------------------------------------------------------------------- /docs/docs/api/allpackages-index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | All Packages (Simple Features GeoJSON 3.3.3 API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 33 | 36 |
37 | 94 |
95 |
96 |
97 |

All Packages

98 |
99 |
100 | 121 |
122 |
123 | 170 | 171 | 172 | -------------------------------------------------------------------------------- /docs/docs/api/constant-values.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Constant Field Values (Simple Features GeoJSON 3.3.3 API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 33 | 36 |
37 | 94 |
95 |
96 |
97 |

Constant Field Values

98 |
99 |

Contents

100 |
101 |
102 |
103 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /docs/docs/api/deprecated-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Deprecated List (Simple Features GeoJSON 3.3.3 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.geojson 2 | mil.nga.sf.geojson.jackson 3 | -------------------------------------------------------------------------------- /docs/docs/api/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Overview (Simple Features GeoJSON 3.3.3 API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 33 | 36 |
37 | 94 |
95 |
96 |

Simple Features GeoJSON 3.3.3 API

97 |
98 |
99 |
100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 |
Packages 
PackageDescription
mil.nga.sf.geojson 
mil.nga.sf.geojson.jackson 
117 |
118 |
119 | 166 | 167 | 168 | -------------------------------------------------------------------------------- /docs/docs/api/jquery/images/ui-bg_glass_55_fbf9ee_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngageoint/simple-features-geojson-java/f0c7b96acf2ffbcc892d85379e17803e17d080ff/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-geojson-java/f0c7b96acf2ffbcc892d85379e17803e17d080ff/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-geojson-java/f0c7b96acf2ffbcc892d85379e17803e17d080ff/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-geojson-java/f0c7b96acf2ffbcc892d85379e17803e17d080ff/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-geojson-java/f0c7b96acf2ffbcc892d85379e17803e17d080ff/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-geojson-java/f0c7b96acf2ffbcc892d85379e17803e17d080ff/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-geojson-java/f0c7b96acf2ffbcc892d85379e17803e17d080ff/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-geojson-java/f0c7b96acf2ffbcc892d85379e17803e17d080ff/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-geojson-java/f0c7b96acf2ffbcc892d85379e17803e17d080ff/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-geojson-java/f0c7b96acf2ffbcc892d85379e17803e17d080ff/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-geojson-java/f0c7b96acf2ffbcc892d85379e17803e17d080ff/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 Class mil.nga.sf.geojson.FeatureConverter (Simple Features GeoJSON 3.3.3 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.geojson.FeatureConverter

98 |
99 |
No usage of mil.nga.sf.geojson.FeatureConverter
100 |
101 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /docs/docs/api/mil/nga/sf/geojson/class-use/GeometryCollection.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class mil.nga.sf.geojson.GeometryCollection (Simple Features GeoJSON 3.3.3 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.geojson.GeometryCollection

98 |
99 |
No usage of mil.nga.sf.geojson.GeometryCollection
100 |
101 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /docs/docs/api/mil/nga/sf/geojson/jackson/class-use/CoordinatesDeserializer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class mil.nga.sf.geojson.jackson.CoordinatesDeserializer (Simple Features GeoJSON 3.3.3 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.geojson.jackson.CoordinatesDeserializer

98 |
99 |
No usage of mil.nga.sf.geojson.jackson.CoordinatesDeserializer
100 |
101 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /docs/docs/api/mil/nga/sf/geojson/jackson/class-use/CoordinatesSerializer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class mil.nga.sf.geojson.jackson.CoordinatesSerializer (Simple Features GeoJSON 3.3.3 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.geojson.jackson.CoordinatesSerializer

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

Package mil.nga.sf.geojson.jackson

98 |
99 |
100 |
    101 |
  • 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 114 | 115 | 116 | 117 | 120 | 121 | 122 |
    Class Summary 
    ClassDescription
    CoordinatesDeserializer 112 |
    Coordinates Deserializer
    113 |
    CoordinatesSerializer 118 |
    Coordinates Serializer
    119 |
    123 |
  • 124 |
125 |
126 |
127 | 174 | 175 | 176 | -------------------------------------------------------------------------------- /docs/docs/api/mil/nga/sf/geojson/jackson/package-tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | mil.nga.sf.geojson.jackson Class Hierarchy (Simple Features GeoJSON 3.3.3 API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 33 | 36 |
37 | 94 |
95 |
96 |
97 |

Hierarchy For Package mil.nga.sf.geojson.jackson

98 | Package Hierarchies: 99 | 102 |
103 |
104 |
105 |

Class Hierarchy

106 |
    107 |
  • java.lang.Object 108 |
      109 |
    • com.fasterxml.jackson.databind.JsonDeserializer<T> (implements com.fasterxml.jackson.databind.deser.NullValueProvider) 110 | 113 |
    • 114 |
    • com.fasterxml.jackson.databind.JsonSerializer<T> (implements com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitable) 115 | 118 |
    • 119 |
    120 |
  • 121 |
122 |
123 |
124 |
125 | 172 | 173 | 174 | -------------------------------------------------------------------------------- /docs/docs/api/mil/nga/sf/geojson/jackson/package-use.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Package mil.nga.sf.geojson.jackson (Simple Features GeoJSON 3.3.3 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.geojson.jackson

98 |
99 |
No usage of mil.nga.sf.geojson.jackson
100 |
101 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /docs/docs/api/overview-summary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Simple Features GeoJSON 3.3.3 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.geojson"},{"l":"mil.nga.sf.geojson.jackson"}] -------------------------------------------------------------------------------- /docs/docs/api/package-search-index.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngageoint/simple-features-geojson-java/f0c7b96acf2ffbcc892d85379e17803e17d080ff/docs/docs/api/package-search-index.zip -------------------------------------------------------------------------------- /docs/docs/api/resources/glass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngageoint/simple-features-geojson-java/f0c7b96acf2ffbcc892d85379e17803e17d080ff/docs/docs/api/resources/glass.png -------------------------------------------------------------------------------- /docs/docs/api/resources/x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngageoint/simple-features-geojson-java/f0c7b96acf2ffbcc892d85379e17803e17d080ff/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.geojson.jackson","l":"CoordinatesDeserializer"},{"p":"mil.nga.sf.geojson.jackson","l":"CoordinatesSerializer"},{"p":"mil.nga.sf.geojson","l":"Feature"},{"p":"mil.nga.sf.geojson","l":"FeatureCollection"},{"p":"mil.nga.sf.geojson","l":"FeatureConverter"},{"p":"mil.nga.sf.geojson","l":"GeoJsonObject"},{"p":"mil.nga.sf.geojson","l":"Geometry"},{"p":"mil.nga.sf.geojson","l":"GeometryCollection"},{"p":"mil.nga.sf.geojson","l":"GeometryType"},{"p":"mil.nga.sf.geojson","l":"LineString"},{"p":"mil.nga.sf.geojson","l":"MultiLineString"},{"p":"mil.nga.sf.geojson","l":"MultiPoint"},{"p":"mil.nga.sf.geojson","l":"MultiPolygon"},{"p":"mil.nga.sf.geojson","l":"Point"},{"p":"mil.nga.sf.geojson","l":"Polygon"},{"p":"mil.nga.sf.geojson","l":"Position"}] -------------------------------------------------------------------------------- /docs/docs/api/type-search-index.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngageoint/simple-features-geojson-java/f0c7b96acf2ffbcc892d85379e17803e17d080ff/docs/docs/api/type-search-index.zip -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Simple Features GeoJSON Java 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 22 | 23 |
24 | 25 |

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

Simple Features GeoJSON is a Java library for writing and reading Simple Feature Geometries to and from GeoJSON.

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 | -------------------------------------------------------------------------------- /docs/stylesheets/stylesheet.css: -------------------------------------------------------------------------------- 1 | * { 2 | box-sizing: border-box; } 3 | 4 | body { 5 | padding: 0; 6 | margin: 0; 7 | font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; 8 | font-size: 16px; 9 | line-height: 1.5; 10 | color: #606c71; } 11 | 12 | a { 13 | color: #1e6bb8; 14 | text-decoration: none; } 15 | a:hover { 16 | text-decoration: underline; } 17 | 18 | .btn { 19 | display: inline-block; 20 | margin-bottom: 1rem; 21 | color: rgba(255, 255, 255, 0.7); 22 | background-color: rgba(255, 255, 255, 0.08); 23 | border-color: rgba(255, 255, 255, 0.2); 24 | border-style: solid; 25 | border-width: 1px; 26 | border-radius: 0.3rem; 27 | transition: color 0.2s, background-color 0.2s, border-color 0.2s; } 28 | .btn + .btn { 29 | margin-left: 1rem; } 30 | 31 | .btn:hover { 32 | color: rgba(255, 255, 255, 0.8); 33 | text-decoration: none; 34 | background-color: rgba(255, 255, 255, 0.2); 35 | border-color: rgba(255, 255, 255, 0.3); } 36 | 37 | @media screen and (min-width: 64em) { 38 | .btn { 39 | padding: 0.75rem 1rem; } } 40 | 41 | @media screen and (min-width: 42em) and (max-width: 64em) { 42 | .btn { 43 | padding: 0.6rem 0.9rem; 44 | font-size: 0.9rem; } } 45 | 46 | @media screen and (max-width: 42em) { 47 | .btn { 48 | display: block; 49 | width: 100%; 50 | padding: 0.75rem; 51 | font-size: 0.9rem; } 52 | .btn + .btn { 53 | margin-top: 1rem; 54 | margin-left: 0; } } 55 | 56 | .page-header { 57 | color: #fff; 58 | text-align: center; 59 | background-color: #159957; 60 | background-image: linear-gradient(120deg, #155799, #159957); } 61 | 62 | @media screen and (min-width: 64em) { 63 | .page-header { 64 | padding: 5rem 6rem; } } 65 | 66 | @media screen and (min-width: 42em) and (max-width: 64em) { 67 | .page-header { 68 | padding: 3rem 4rem; } } 69 | 70 | @media screen and (max-width: 42em) { 71 | .page-header { 72 | padding: 2rem 1rem; } } 73 | 74 | .project-name { 75 | margin-top: 0; 76 | margin-bottom: 0.1rem; } 77 | 78 | @media screen and (min-width: 64em) { 79 | .project-name { 80 | font-size: 3.25rem; } } 81 | 82 | @media screen and (min-width: 42em) and (max-width: 64em) { 83 | .project-name { 84 | font-size: 2.25rem; } } 85 | 86 | @media screen and (max-width: 42em) { 87 | .project-name { 88 | font-size: 1.75rem; } } 89 | 90 | .project-tagline { 91 | margin-bottom: 2rem; 92 | font-weight: normal; 93 | opacity: 0.7; } 94 | 95 | @media screen and (min-width: 64em) { 96 | .project-tagline { 97 | font-size: 1.25rem; } } 98 | 99 | @media screen and (min-width: 42em) and (max-width: 64em) { 100 | .project-tagline { 101 | font-size: 1.15rem; } } 102 | 103 | @media screen and (max-width: 42em) { 104 | .project-tagline { 105 | font-size: 1rem; } } 106 | 107 | .main-content :first-child { 108 | margin-top: 0; } 109 | .main-content img { 110 | max-width: 100%; } 111 | .main-content h1, .main-content h2, .main-content h3, .main-content h4, .main-content h5, .main-content h6 { 112 | margin-top: 2rem; 113 | margin-bottom: 1rem; 114 | font-weight: normal; 115 | color: #159957; } 116 | .main-content p { 117 | margin-bottom: 1em; } 118 | .main-content code { 119 | padding: 2px 4px; 120 | font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; 121 | font-size: 0.9rem; 122 | color: #383e41; 123 | background-color: #f3f6fa; 124 | border-radius: 0.3rem; } 125 | .main-content pre { 126 | padding: 0.8rem; 127 | margin-top: 0; 128 | margin-bottom: 1rem; 129 | font: 1rem Consolas, "Liberation Mono", Menlo, Courier, monospace; 130 | color: #567482; 131 | word-wrap: normal; 132 | background-color: #f3f6fa; 133 | border: solid 1px #dce6f0; 134 | border-radius: 0.3rem; } 135 | .main-content pre > code { 136 | padding: 0; 137 | margin: 0; 138 | font-size: 0.9rem; 139 | color: #567482; 140 | word-break: normal; 141 | white-space: pre; 142 | background: transparent; 143 | border: 0; } 144 | .main-content .highlight { 145 | margin-bottom: 1rem; } 146 | .main-content .highlight pre { 147 | margin-bottom: 0; 148 | word-break: normal; } 149 | .main-content .highlight pre, .main-content pre { 150 | padding: 0.8rem; 151 | overflow: auto; 152 | font-size: 0.9rem; 153 | line-height: 1.45; 154 | border-radius: 0.3rem; } 155 | .main-content pre code, .main-content pre tt { 156 | display: inline; 157 | max-width: initial; 158 | padding: 0; 159 | margin: 0; 160 | overflow: initial; 161 | line-height: inherit; 162 | word-wrap: normal; 163 | background-color: transparent; 164 | border: 0; } 165 | .main-content pre code:before, .main-content pre code:after, .main-content pre tt:before, .main-content pre tt:after { 166 | content: normal; } 167 | .main-content ul, .main-content ol { 168 | margin-top: 0; } 169 | .main-content blockquote { 170 | padding: 0 1rem; 171 | margin-left: 0; 172 | color: #819198; 173 | border-left: 0.3rem solid #dce6f0; } 174 | .main-content blockquote > :first-child { 175 | margin-top: 0; } 176 | .main-content blockquote > :last-child { 177 | margin-bottom: 0; } 178 | .main-content table { 179 | display: block; 180 | width: 100%; 181 | overflow: auto; 182 | word-break: normal; 183 | word-break: keep-all; } 184 | .main-content table th { 185 | font-weight: bold; } 186 | .main-content table th, .main-content table td { 187 | padding: 0.5rem 1rem; 188 | border: 1px solid #e9ebec; } 189 | .main-content dl { 190 | padding: 0; } 191 | .main-content dl dt { 192 | padding: 0; 193 | margin-top: 1rem; 194 | font-size: 1rem; 195 | font-weight: bold; } 196 | .main-content dl dd { 197 | padding: 0; 198 | margin-bottom: 1rem; } 199 | .main-content hr { 200 | height: 2px; 201 | padding: 0; 202 | margin: 1rem 0; 203 | background-color: #eff0f1; 204 | border: 0; } 205 | 206 | @media screen and (min-width: 64em) { 207 | .main-content { 208 | max-width: 64rem; 209 | padding: 2rem 6rem; 210 | margin: 0 auto; 211 | font-size: 1.1rem; } } 212 | 213 | @media screen and (min-width: 42em) and (max-width: 64em) { 214 | .main-content { 215 | padding: 2rem 4rem; 216 | font-size: 1.1rem; } } 217 | 218 | @media screen and (max-width: 42em) { 219 | .main-content { 220 | padding: 2rem 1rem; 221 | font-size: 1rem; } } 222 | 223 | .site-footer { 224 | padding-top: 2rem; 225 | margin-top: 2rem; 226 | border-top: solid 1px #eff0f1; } 227 | 228 | .site-footer-owner { 229 | display: block; 230 | font-weight: bold; } 231 | 232 | .site-footer-credits { 233 | color: #819198; } 234 | 235 | @media screen and (min-width: 64em) { 236 | .site-footer { 237 | font-size: 1rem; } } 238 | 239 | @media screen and (min-width: 42em) and (max-width: 64em) { 240 | .site-footer { 241 | font-size: 1rem; } } 242 | 243 | @media screen and (max-width: 42em) { 244 | .site-footer { 245 | font-size: 0.9rem; } } 246 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | mil.nga.sf 5 | sf-geojson 6 | 3.3.4 7 | jar 8 | Simple Features GeoJSON 9 | https://github.com/ngageoint/simple-features-geojson-java 10 | Library for writing and reading Simple Feature Geometries to and from GeoJSON 11 | 12 | git@github.com:ngageoint/simple-features-geojson-java.git 13 | scm:git:git@github.com:ngageoint/simple-features-geojson-java.git 14 | scm:git:git@github.com:ngageoint/simple-features-geojson-java.git 15 | 16 | 17 | 18 | The MIT License (MIT) 19 | https://github.com/ngageoint/simple-features-geojson-java/blob/master/LICENSE.txt 20 | repo 21 | 22 | 23 | 24 | National Geospatial-Intelligence Agency 25 | https://www.nga.mil/ 26 | 27 | 28 | 29 | yutzlejp 30 | Jeff Yutzler 31 | UTC−05 32 | 33 | 34 | bosborn 35 | Brian Osborn 36 | bosborn@caci.com 37 | BIT Systems 38 | https://www.caci.com/bit-systems 39 | 40 | developer 41 | 42 | UTC−07 43 | 44 | 45 | 46 | 11 47 | 11 48 | UTF-8 49 | 50 | 51 | 52 | mil.nga 53 | sf 54 | 2.2.2 55 | 56 | 57 | com.fasterxml.jackson.core 58 | jackson-databind 59 | 2.17.0 60 | 61 | 62 | junit 63 | junit 64 | 4.13.2 65 | test 66 | 67 | 68 | 69 | 70 | 71 | 72 | org.apache.maven.plugins 73 | maven-source-plugin 74 | 3.3.0 75 | 76 | 77 | attach-sources 78 | 79 | jar-no-fork 80 | 81 | 82 | 83 | 84 | 85 | org.apache.maven.plugins 86 | maven-javadoc-plugin 87 | 3.6.3 88 | 89 | 90 | http://ngageoint.github.io/simple-features-java/docs/api/ 91 | 92 | 93 | 94 | 95 | attach-javadocs 96 | 97 | jar 98 | 99 | 100 | -Xdoclint:none 101 | 102 | 103 | 104 | 105 | 106 | org.apache.maven.plugins 107 | maven-gpg-plugin 108 | 3.2.2 109 | 110 | 111 | sign-artifacts 112 | deploy 113 | 114 | sign 115 | 116 | 117 | 118 | 119 | 120 | org.sonatype.plugins 121 | nexus-staging-maven-plugin 122 | 1.6.13 123 | true 124 | 125 | ossrh 126 | https://oss.sonatype.org/ 127 | true 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | ossrh 136 | https://oss.sonatype.org/content/repositories/snapshots 137 | 138 | 139 | ossrh 140 | https://oss.sonatype.org/service/local/staging/deploy/maven2/ 141 | 142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/geojson/Feature.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.geojson; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import com.fasterxml.jackson.annotation.JsonIgnore; 7 | import com.fasterxml.jackson.annotation.JsonInclude; 8 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; 9 | 10 | /** 11 | * Feature 12 | * 13 | * @author yutzlejp 14 | */ 15 | @JsonPropertyOrder({ "type", "bbox", "id", "geometry", "properties" }) 16 | public class Feature extends GeoJsonObject { 17 | 18 | /** 19 | * Serialization Version number 20 | */ 21 | private static final long serialVersionUID = 2L; 22 | 23 | /** 24 | * Feature id 25 | */ 26 | private String id; 27 | 28 | /** 29 | * Geometry 30 | */ 31 | private Geometry geometry = null; 32 | 33 | /** 34 | * Properties map 35 | */ 36 | private Map properties = new HashMap<>(); 37 | 38 | /** 39 | * Constructor 40 | */ 41 | public Feature() { 42 | 43 | } 44 | 45 | /** 46 | * Constructor 47 | * 48 | * @param geometry 49 | * geometry 50 | */ 51 | public Feature(Geometry geometry) { 52 | this.geometry = geometry; 53 | } 54 | 55 | /** 56 | * Get the feature id 57 | * 58 | * @return feature id 59 | */ 60 | public String getId() { 61 | return id; 62 | } 63 | 64 | /** 65 | * Set the feature id 66 | * 67 | * @param id 68 | * feature id 69 | */ 70 | public void setId(String id) { 71 | this.id = id; 72 | } 73 | 74 | /** 75 | * Get the geometry 76 | * 77 | * @return geometry 78 | */ 79 | @JsonInclude(JsonInclude.Include.ALWAYS) 80 | public Geometry getGeometry() { 81 | return geometry; 82 | } 83 | 84 | /** 85 | * Set the geometry 86 | * 87 | * @param geometry 88 | * geometry object 89 | */ 90 | public void setGeometry(Geometry geometry) { 91 | this.geometry = geometry; 92 | } 93 | 94 | /** 95 | * Get the properties 96 | * 97 | * @return properties map 98 | */ 99 | @JsonInclude(JsonInclude.Include.ALWAYS) 100 | public Map getProperties() { 101 | return properties; 102 | } 103 | 104 | /** 105 | * Set the properties 106 | * 107 | * @param properties 108 | * properties map 109 | */ 110 | public void setProperties(Map properties) { 111 | this.properties = properties; 112 | } 113 | 114 | /** 115 | * {@inheritDoc} 116 | */ 117 | @Override 118 | public mil.nga.sf.Geometry getSimpleGeometry() { 119 | return geometry != null ? geometry.getGeometry() : null; 120 | } 121 | 122 | /** 123 | * Get the geometry type 124 | * 125 | * @return geometry type 126 | * @since 3.0.0 127 | */ 128 | @JsonIgnore 129 | public GeometryType getGeometryType() { 130 | return geometry != null ? geometry.getGeometryType() : null; 131 | } 132 | 133 | /** 134 | * {@inheritDoc} 135 | */ 136 | @Override 137 | public String getType() { 138 | return "Feature"; 139 | } 140 | 141 | /** 142 | * {@inheritDoc} 143 | */ 144 | @Override 145 | public int hashCode() { 146 | final int prime = 31; 147 | int result = super.hashCode(); 148 | result = prime * result 149 | + ((geometry == null) ? 0 : geometry.hashCode()); 150 | result = prime * result + ((id == null) ? 0 : id.hashCode()); 151 | result = prime * result 152 | + ((properties == null) ? 0 : properties.hashCode()); 153 | return result; 154 | } 155 | 156 | /** 157 | * {@inheritDoc} 158 | */ 159 | @Override 160 | public boolean equals(Object obj) { 161 | if (this == obj) 162 | return true; 163 | if (!super.equals(obj)) 164 | return false; 165 | if (getClass() != obj.getClass()) 166 | return false; 167 | Feature other = (Feature) obj; 168 | if (geometry == null) { 169 | if (other.geometry != null) 170 | return false; 171 | } else if (!geometry.equals(other.geometry)) 172 | return false; 173 | if (id == null) { 174 | if (other.id != null) 175 | return false; 176 | } else if (!id.equals(other.id)) 177 | return false; 178 | if (properties == null) { 179 | if (other.properties != null) 180 | return false; 181 | } else if (!properties.equals(other.properties)) 182 | return false; 183 | return true; 184 | } 185 | 186 | } 187 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/geojson/FeatureCollection.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.geojson; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collection; 5 | import java.util.HashMap; 6 | import java.util.Iterator; 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | import com.fasterxml.jackson.annotation.JsonIgnore; 11 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; 12 | 13 | import mil.nga.sf.GeometryCollection; 14 | 15 | /** 16 | * Feature Collection 17 | * 18 | * @author yutzlejp 19 | */ 20 | @JsonPropertyOrder({ "type", "bbox", "features" }) 21 | public class FeatureCollection extends GeoJsonObject 22 | implements Iterable { 23 | 24 | /** 25 | * Serialization Version number 26 | */ 27 | private static final long serialVersionUID = 1L; 28 | 29 | /** 30 | * Collection of features 31 | */ 32 | private List features = new ArrayList<>(); 33 | 34 | /** 35 | * Constructor 36 | */ 37 | public FeatureCollection() { 38 | } 39 | 40 | /** 41 | * Constructor 42 | * 43 | * @param feature 44 | * feature 45 | */ 46 | public FeatureCollection(Feature feature) { 47 | addFeature(feature); 48 | } 49 | 50 | /** 51 | * Constructor 52 | * 53 | * @param features 54 | * collection of features 55 | */ 56 | public FeatureCollection(Collection features) { 57 | setFeatures(features); 58 | } 59 | 60 | /** 61 | * Get the features 62 | * 63 | * @return collection of features 64 | */ 65 | public List getFeatures() { 66 | return features; 67 | } 68 | 69 | /** 70 | * Set the features 71 | * 72 | * @param features 73 | * collection of features 74 | */ 75 | public void setFeatures(Collection features) { 76 | this.features = new ArrayList<>(features); 77 | } 78 | 79 | /** 80 | * Add a feature 81 | * 82 | * @param feature 83 | * feature 84 | */ 85 | public void addFeature(Feature feature) { 86 | features.add(feature); 87 | } 88 | 89 | /** 90 | * Add the features 91 | * 92 | * @param features 93 | * collection of features 94 | */ 95 | public void addFeatures(Collection features) { 96 | this.features.addAll(features); 97 | } 98 | 99 | /** 100 | * Get the number of features 101 | * 102 | * @return feature count 103 | */ 104 | public int numFeatures() { 105 | return features.size(); 106 | } 107 | 108 | /** 109 | * Get the feature at the index 110 | * 111 | * @param i 112 | * index 113 | * @return feature 114 | */ 115 | public Feature getFeature(int i) { 116 | return features.get(i); 117 | } 118 | 119 | /** 120 | * {@inheritDoc} 121 | */ 122 | @Override 123 | public Iterator iterator() { 124 | return features.iterator(); 125 | } 126 | 127 | /** 128 | * {@inheritDoc} 129 | */ 130 | @Override 131 | public mil.nga.sf.Geometry getSimpleGeometry() { 132 | mil.nga.sf.Geometry geometry = null; 133 | if (features != null && !features.isEmpty()) { 134 | GeometryCollection geomCollection = new GeometryCollection<>(); 135 | for (Feature feature : features) { 136 | mil.nga.sf.Geometry geom = feature.getSimpleGeometry(); 137 | if (geom != null) { 138 | geomCollection.addGeometry(geom); 139 | } 140 | } 141 | if (!geomCollection.isEmpty()) { 142 | geometry = geomCollection; 143 | } 144 | } 145 | return geometry; 146 | } 147 | 148 | /** 149 | * Get the geometry type 150 | * 151 | * @return geometry type 152 | * @since 3.0.0 153 | */ 154 | @JsonIgnore 155 | public GeometryType getGeometryType() { 156 | GeometryType result = null; 157 | 158 | for (Feature feature : features) { 159 | GeometryType gt = feature.getGeometryType(); 160 | if (result == null) { 161 | result = gt; 162 | } else if (gt != result) { 163 | result = GeometryType.GEOMETRY; 164 | break; 165 | } 166 | } 167 | 168 | return result; 169 | } 170 | 171 | /** 172 | * Get the properties map 173 | * 174 | * @return properties map 175 | */ 176 | @JsonIgnore 177 | public Map getPropertiesMap() { 178 | Map result = new HashMap<>(); 179 | for (Feature feature : getFeatures()) { 180 | Map properties = feature.getProperties(); 181 | for (final String property : properties.keySet()) { 182 | if (!result.containsKey(property)) { 183 | result.put(property, properties.get(property).getClass() 184 | .getSimpleName()); 185 | } 186 | } 187 | } 188 | return result; 189 | } 190 | 191 | /** 192 | * {@inheritDoc} 193 | */ 194 | @Override 195 | public String getType() { 196 | return "FeatureCollection"; 197 | } 198 | 199 | /** 200 | * {@inheritDoc} 201 | */ 202 | @Override 203 | public int hashCode() { 204 | final int prime = 31; 205 | int result = super.hashCode(); 206 | result = prime * result 207 | + ((features == null) ? 0 : features.hashCode()); 208 | return result; 209 | } 210 | 211 | /** 212 | * {@inheritDoc} 213 | */ 214 | @Override 215 | public boolean equals(Object obj) { 216 | if (this == obj) 217 | return true; 218 | if (!super.equals(obj)) 219 | return false; 220 | if (getClass() != obj.getClass()) 221 | return false; 222 | FeatureCollection other = (FeatureCollection) obj; 223 | if (features == null) { 224 | if (other.features != null) 225 | return false; 226 | } else if (!features.equals(other.features)) 227 | return false; 228 | return true; 229 | } 230 | 231 | } 232 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/geojson/GeoJsonObject.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.geojson; 2 | 3 | import java.io.Serializable; 4 | import java.util.Arrays; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 9 | import com.fasterxml.jackson.annotation.JsonAnySetter; 10 | import com.fasterxml.jackson.annotation.JsonIgnore; 11 | import com.fasterxml.jackson.annotation.JsonInclude; 12 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 13 | import com.fasterxml.jackson.annotation.JsonSubTypes; 14 | import com.fasterxml.jackson.annotation.JsonSubTypes.Type; 15 | import com.fasterxml.jackson.annotation.JsonTypeInfo; 16 | import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; 17 | 18 | /** 19 | * GeoJSON Object 20 | * 21 | * @author yutzlejp 22 | */ 23 | @JsonTypeInfo(property = "type", use = Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY) 24 | @JsonSubTypes({ @Type(Feature.class), @Type(FeatureCollection.class), 25 | @Type(Geometry.class) }) 26 | @JsonInclude(Include.NON_EMPTY) 27 | public abstract class GeoJsonObject implements Serializable { 28 | 29 | /** 30 | * Serialization Version number 31 | */ 32 | private static final long serialVersionUID = 1L; 33 | 34 | /** 35 | * Bounding box 36 | */ 37 | private double[] bbox; 38 | 39 | /** 40 | * Foreign members 41 | */ 42 | private Map foreignMembers = new HashMap<>(); 43 | 44 | /** 45 | * Get the bounding box 46 | * 47 | * @return bounding box 48 | */ 49 | public double[] getBbox() { 50 | return bbox; 51 | } 52 | 53 | /** 54 | * Set the bounding box 55 | * 56 | * @param bbox 57 | * bounding box 58 | */ 59 | public void setBbox(double[] bbox) { 60 | this.bbox = bbox; 61 | } 62 | 63 | /** 64 | * Get the GeoJSON object type 65 | * 66 | * @return GeoJSON object type 67 | */ 68 | public abstract String getType(); 69 | 70 | /** 71 | * Get the simple feature geometry 72 | * 73 | * @return simple feature geometry 74 | * @since 3.3.3 75 | */ 76 | @JsonIgnore 77 | public abstract mil.nga.sf.Geometry getSimpleGeometry(); 78 | 79 | /** 80 | * Get the foreign members 81 | * 82 | * @return foreign members 83 | */ 84 | @JsonAnyGetter 85 | public Map getForeignMembers() { 86 | return foreignMembers; 87 | } 88 | 89 | /** 90 | * Get the foreign member by name 91 | * 92 | * @param name 93 | * name 94 | * @return value 95 | */ 96 | public Object getForeignMember(String name) { 97 | return foreignMembers.get(name); 98 | } 99 | 100 | /** 101 | * Check if has the foreign member 102 | * 103 | * @param name 104 | * name 105 | * @return true if has 106 | */ 107 | public Object hasForeignMember(String name) { 108 | return foreignMembers.containsKey(name); 109 | } 110 | 111 | /** 112 | * Set a foreign member 113 | * 114 | * @param name 115 | * name 116 | * @param value 117 | * value 118 | */ 119 | @JsonAnySetter 120 | public void setForeignMember(String name, Object value) { 121 | foreignMembers.put(name, value); 122 | } 123 | 124 | /** 125 | * Check if has foreign members 126 | * 127 | * @return true if has 128 | */ 129 | public boolean hasForeignMembers() { 130 | return !foreignMembers.isEmpty(); 131 | } 132 | 133 | /** 134 | * {@inheritDoc} 135 | */ 136 | @Override 137 | public int hashCode() { 138 | final int prime = 31; 139 | int result = 1; 140 | result = prime * result + Arrays.hashCode(bbox); 141 | result = prime * result 142 | + ((foreignMembers == null) ? 0 : foreignMembers.hashCode()); 143 | return result; 144 | } 145 | 146 | /** 147 | * {@inheritDoc} 148 | */ 149 | @Override 150 | public boolean equals(Object obj) { 151 | if (this == obj) 152 | return true; 153 | if (obj == null) 154 | return false; 155 | if (getClass() != obj.getClass()) 156 | return false; 157 | GeoJsonObject other = (GeoJsonObject) obj; 158 | if (!Arrays.equals(bbox, other.bbox)) 159 | return false; 160 | if (foreignMembers == null) { 161 | if (other.foreignMembers != null) 162 | return false; 163 | } else if (!foreignMembers.equals(other.foreignMembers)) 164 | return false; 165 | return true; 166 | } 167 | 168 | } 169 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/geojson/Geometry.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.geojson; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; 5 | import com.fasterxml.jackson.annotation.JsonSubTypes; 6 | import com.fasterxml.jackson.annotation.JsonSubTypes.Type; 7 | 8 | /** 9 | * Geometry 10 | * 11 | * @author yutzlejp 12 | */ 13 | @JsonSubTypes({ @Type(Polygon.class), @Type(MultiPolygon.class), 14 | @Type(Point.class), @Type(MultiPoint.class), 15 | @Type(MultiLineString.class), @Type(LineString.class), 16 | @Type(GeometryCollection.class) }) 17 | @JsonPropertyOrder({ "type", "bbox" }) 18 | public abstract class Geometry extends GeoJsonObject { 19 | 20 | /** 21 | * Serialization Version number 22 | */ 23 | private static final long serialVersionUID = 2L; 24 | 25 | /** 26 | * Get the geometry type 27 | * 28 | * @return geometry type 29 | * @since 3.0.0 30 | */ 31 | @JsonIgnore 32 | public abstract GeometryType getGeometryType(); 33 | 34 | /** 35 | * Get the simple geometry 36 | * 37 | * @return simple geometry 38 | */ 39 | @JsonIgnore 40 | public abstract mil.nga.sf.Geometry getGeometry(); 41 | 42 | /** 43 | * {@inheritDoc} 44 | */ 45 | @Override 46 | public mil.nga.sf.Geometry getSimpleGeometry() { 47 | return getGeometry(); 48 | } 49 | 50 | /** 51 | * {@inheritDoc} 52 | */ 53 | @Override 54 | public String getType() { 55 | return getGeometryType().getName(); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/geojson/GeometryCollection.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.geojson; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import com.fasterxml.jackson.annotation.JsonIgnore; 7 | 8 | /** 9 | * Geometry Collection 10 | * 11 | * @author osbornb 12 | */ 13 | public class GeometryCollection extends Geometry { 14 | 15 | /** 16 | * Serialization Version number 17 | */ 18 | private static final long serialVersionUID = 2L; 19 | 20 | /** 21 | * List of geometries 22 | */ 23 | private List geometries = null; 24 | 25 | /** 26 | * Constructor 27 | */ 28 | public GeometryCollection() { 29 | 30 | } 31 | 32 | /** 33 | * Constructor 34 | * 35 | * @param geometries 36 | * list of geometries 37 | */ 38 | public GeometryCollection(List geometries) { 39 | this.geometries = geometries; 40 | } 41 | 42 | /** 43 | * Constructor 44 | * 45 | * @param geometryCollection 46 | * simple geometry collection 47 | */ 48 | public GeometryCollection( 49 | mil.nga.sf.GeometryCollection geometryCollection) { 50 | setGeometryCollection(geometryCollection); 51 | } 52 | 53 | /** 54 | * {@inheritDoc} 55 | */ 56 | @Override 57 | public GeometryType getGeometryType() { 58 | return GeometryType.GEOMETRYCOLLECTION; 59 | } 60 | 61 | /** 62 | * {@inheritDoc} 63 | */ 64 | @Override 65 | public mil.nga.sf.Geometry getGeometry() { 66 | return getGeometryCollection(); 67 | } 68 | 69 | /** 70 | * Returns geometries as a GeoJSON Geometry list 71 | * 72 | * @return the geometries 73 | */ 74 | public List getGeometries() { 75 | return geometries; 76 | } 77 | 78 | /** 79 | * Sets the geometries from a GeoJSON Geometry list 80 | * 81 | * @param geometries 82 | * list of geometries 83 | * @since 3.0.0 84 | */ 85 | public void setGeometries(List geometries) { 86 | this.geometries = geometries; 87 | } 88 | 89 | /** 90 | * Get the simple features geometry collection 91 | * 92 | * @return geometry collection 93 | * @since 3.0.0 94 | */ 95 | @JsonIgnore 96 | public mil.nga.sf.GeometryCollection getGeometryCollection() { 97 | mil.nga.sf.GeometryCollection simpleGeometryCollection = new mil.nga.sf.GeometryCollection<>(); 98 | for (Geometry geometry : geometries) { 99 | simpleGeometryCollection.addGeometry(geometry.getGeometry()); 100 | } 101 | return simpleGeometryCollection; 102 | } 103 | 104 | /** 105 | * Set the simple features geometry collection 106 | * 107 | * @param geometryCollection 108 | * geometry collection 109 | * @since 3.0.0 110 | */ 111 | public void setGeometryCollection( 112 | mil.nga.sf.GeometryCollection geometryCollection) { 113 | geometries = new ArrayList<>(); 114 | for (mil.nga.sf.Geometry simpleGeometry : geometryCollection 115 | .getGeometries()) { 116 | geometries.add(FeatureConverter.toGeometry(simpleGeometry)); 117 | } 118 | } 119 | 120 | /** 121 | * {@inheritDoc} 122 | */ 123 | @Override 124 | public int hashCode() { 125 | final int prime = 31; 126 | int result = super.hashCode(); 127 | result = prime * result 128 | + ((geometries == null) ? 0 : geometries.hashCode()); 129 | return result; 130 | } 131 | 132 | /** 133 | * {@inheritDoc} 134 | */ 135 | @Override 136 | public boolean equals(Object obj) { 137 | if (this == obj) 138 | return true; 139 | if (!super.equals(obj)) 140 | return false; 141 | if (getClass() != obj.getClass()) 142 | return false; 143 | GeometryCollection other = (GeometryCollection) obj; 144 | if (geometries == null) { 145 | if (other.geometries != null) 146 | return false; 147 | } else if (!geometries.equals(other.geometries)) 148 | return false; 149 | return true; 150 | } 151 | 152 | } 153 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/geojson/GeometryType.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.geojson; 2 | 3 | /** 4 | * Geometry Type enumeration 5 | * 6 | * @author osbornb 7 | * @since 3.0.0 8 | */ 9 | public enum GeometryType { 10 | 11 | /** 12 | * The root of the geometry type hierarchy 13 | */ 14 | GEOMETRY(mil.nga.sf.GeometryType.GEOMETRY, "Geometry"), 15 | 16 | /** 17 | * A single location in space. Each point has an X and Y coordinate. A point 18 | * MAY optionally also have a Z and/or an M value. 19 | */ 20 | POINT(mil.nga.sf.GeometryType.POINT, "Point"), 21 | 22 | /** 23 | * A Curve that connects two or more points in space. 24 | */ 25 | LINESTRING(mil.nga.sf.GeometryType.LINESTRING, "LineString"), 26 | 27 | /** 28 | * A restricted form of CurvePolygon where each ring is defined as a simple, 29 | * closed LineString. 30 | */ 31 | POLYGON(mil.nga.sf.GeometryType.POLYGON, "Polygon"), 32 | 33 | /** 34 | * A restricted form of GeometryCollection where each Geometry in the 35 | * collection must be of type Point. 36 | */ 37 | MULTIPOINT(mil.nga.sf.GeometryType.MULTIPOINT, "MultiPoint"), 38 | 39 | /** 40 | * A restricted form of MultiCurve where each Curve in the collection must 41 | * be of type LineString. 42 | */ 43 | MULTILINESTRING(mil.nga.sf.GeometryType.MULTILINESTRING, "MultiLineString"), 44 | 45 | /** 46 | * A restricted form of MultiSurface where each Surface in the collection 47 | * must be of type Polygon. 48 | */ 49 | MULTIPOLYGON(mil.nga.sf.GeometryType.MULTIPOLYGON, "MultiPolygon"), 50 | 51 | /** 52 | * A collection of zero or more Geometry instances. 53 | */ 54 | GEOMETRYCOLLECTION(mil.nga.sf.GeometryType.GEOMETRYCOLLECTION, 55 | "GeometryCollection"); 56 | 57 | /** 58 | * Simple Features Type 59 | */ 60 | private final mil.nga.sf.GeometryType type; 61 | 62 | /** 63 | * Name 64 | */ 65 | private final String name; 66 | 67 | /** 68 | * Constructor 69 | * 70 | * @param type 71 | * simple features type 72 | * @param name 73 | * name 74 | */ 75 | private GeometryType(mil.nga.sf.GeometryType type, String name) { 76 | this.type = type; 77 | this.name = name; 78 | } 79 | 80 | /** 81 | * Get the simple features type 82 | * 83 | * @return simple features type 84 | */ 85 | public mil.nga.sf.GeometryType getType() { 86 | return type; 87 | } 88 | 89 | /** 90 | * Get the name 91 | * 92 | * @return name 93 | */ 94 | public String getName() { 95 | return name; 96 | } 97 | 98 | } 99 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/geojson/LineString.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.geojson; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import com.fasterxml.jackson.annotation.JsonIgnore; 7 | 8 | /** 9 | * Line String 10 | * 11 | * @author yutzlejp 12 | */ 13 | public class LineString extends Geometry { 14 | 15 | /** 16 | * Serialization Version number 17 | */ 18 | private static final long serialVersionUID = 2L; 19 | 20 | /** 21 | * List of points 22 | */ 23 | private List points = null; 24 | 25 | /** 26 | * Create a line string from coordinates 27 | * 28 | * @param coordinates 29 | * coordinates 30 | * @return line string 31 | * @since 3.0.0 32 | */ 33 | public static LineString fromCoordinates(List coordinates) { 34 | LineString lineString = new LineString(); 35 | lineString.setCoordinates(coordinates); 36 | return lineString; 37 | } 38 | 39 | /** 40 | * Constructor 41 | */ 42 | public LineString() { 43 | 44 | } 45 | 46 | /** 47 | * Constructor 48 | * 49 | * @param points 50 | * list of points 51 | * @since 3.0.0 52 | */ 53 | public LineString(List points) { 54 | this.points = points; 55 | } 56 | 57 | /** 58 | * Constructor 59 | * 60 | * @param lineString 61 | * simple line string 62 | */ 63 | public LineString(mil.nga.sf.LineString lineString) { 64 | setLineString(lineString); 65 | } 66 | 67 | /** 68 | * {@inheritDoc} 69 | */ 70 | @Override 71 | public GeometryType getGeometryType() { 72 | return GeometryType.LINESTRING; 73 | } 74 | 75 | /** 76 | * {@inheritDoc} 77 | */ 78 | @Override 79 | public mil.nga.sf.Geometry getGeometry() { 80 | return getLineString(); 81 | } 82 | 83 | /** 84 | * Get the coordinates 85 | * 86 | * @return list of positions 87 | */ 88 | public List getCoordinates() { 89 | List coordinates = new ArrayList<>(); 90 | for (Point point : points) { 91 | coordinates.add(point.getCoordinates()); 92 | } 93 | return coordinates; 94 | } 95 | 96 | /** 97 | * Set the coordinates 98 | * 99 | * @param coordinates 100 | * coordinates 101 | */ 102 | public void setCoordinates(List coordinates) { 103 | points = new ArrayList<>(); 104 | for (Position position : coordinates) { 105 | points.add(Point.fromCoordinates(position)); 106 | } 107 | } 108 | 109 | /** 110 | * Get the simple features line string 111 | * 112 | * @return line string 113 | * @since 3.0.0 114 | */ 115 | @JsonIgnore 116 | public mil.nga.sf.LineString getLineString() { 117 | List simplePoints = new ArrayList<>(); 118 | for (Point point : points) { 119 | simplePoints.add(point.getPoint()); 120 | } 121 | return new mil.nga.sf.LineString(simplePoints); 122 | } 123 | 124 | /** 125 | * Set the simple features line string 126 | * 127 | * @param lineString 128 | * line string 129 | * @since 3.0.0 130 | */ 131 | public void setLineString(mil.nga.sf.LineString lineString) { 132 | points = new ArrayList<>(); 133 | for (mil.nga.sf.Point point : lineString.getPoints()) { 134 | points.add(new Point(point)); 135 | } 136 | } 137 | 138 | /** 139 | * {@inheritDoc} 140 | */ 141 | @Override 142 | public int hashCode() { 143 | final int prime = 31; 144 | int result = super.hashCode(); 145 | result = prime * result + ((points == null) ? 0 : points.hashCode()); 146 | return result; 147 | } 148 | 149 | /** 150 | * {@inheritDoc} 151 | */ 152 | @Override 153 | public boolean equals(Object obj) { 154 | if (this == obj) 155 | return true; 156 | if (!super.equals(obj)) 157 | return false; 158 | if (getClass() != obj.getClass()) 159 | return false; 160 | LineString other = (LineString) obj; 161 | if (points == null) { 162 | if (other.points != null) 163 | return false; 164 | } else if (!points.equals(other.points)) 165 | return false; 166 | return true; 167 | } 168 | 169 | } 170 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/geojson/MultiLineString.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.geojson; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import com.fasterxml.jackson.annotation.JsonIgnore; 7 | 8 | /** 9 | * Multi Line String 10 | * 11 | * @author yutzlejp 12 | */ 13 | public class MultiLineString extends Geometry { 14 | 15 | /** 16 | * Serialization Version number 17 | */ 18 | private static final long serialVersionUID = 2L; 19 | 20 | /** 21 | * List of line strings 22 | */ 23 | private List lineStrings = null; 24 | 25 | /** 26 | * Create a multi line string from coordinates 27 | * 28 | * @param coordinates 29 | * coordinates 30 | * @return multi line string 31 | * @since 3.0.0 32 | */ 33 | public static MultiLineString fromCoordinates( 34 | List> coordinates) { 35 | MultiLineString multiLineString = new MultiLineString(); 36 | multiLineString.setCoordinates(coordinates); 37 | return multiLineString; 38 | } 39 | 40 | /** 41 | * Constructor 42 | */ 43 | public MultiLineString() { 44 | 45 | } 46 | 47 | /** 48 | * Constructor 49 | * 50 | * @param lineStrings 51 | * line string list 52 | * @since 3.0.0 53 | */ 54 | public MultiLineString(List lineStrings) { 55 | this.lineStrings = lineStrings; 56 | } 57 | 58 | /** 59 | * Constructor 60 | * 61 | * @param multiLineString 62 | * simple multi line string 63 | */ 64 | public MultiLineString(mil.nga.sf.MultiLineString multiLineString) { 65 | setMultiLineString(multiLineString); 66 | } 67 | 68 | /** 69 | * {@inheritDoc} 70 | */ 71 | @Override 72 | public GeometryType getGeometryType() { 73 | return GeometryType.MULTILINESTRING; 74 | } 75 | 76 | /** 77 | * {@inheritDoc} 78 | */ 79 | @Override 80 | public mil.nga.sf.Geometry getGeometry() { 81 | return getMultiLineString(); 82 | } 83 | 84 | /** 85 | * Returns coordinates as a GeoJSON Position list 86 | * 87 | * @return the coordinates 88 | */ 89 | public List> getCoordinates() { 90 | List> coordinates = new ArrayList<>(); 91 | for (LineString lineString : lineStrings) { 92 | coordinates.add(lineString.getCoordinates()); 93 | } 94 | return coordinates; 95 | } 96 | 97 | /** 98 | * Sets the coordinates from a GeoJSON Position list 99 | * 100 | * @param coordinates 101 | * coordinates 102 | * @since 3.0.0 103 | */ 104 | public void setCoordinates(List> coordinates) { 105 | lineStrings = new ArrayList<>(); 106 | for (List positions : coordinates) { 107 | lineStrings.add(LineString.fromCoordinates(positions)); 108 | } 109 | } 110 | 111 | /** 112 | * Get the line strings 113 | * 114 | * @return list of line strings 115 | * @since 3.0.0 116 | */ 117 | @JsonIgnore 118 | public List getLineStrings() { 119 | return lineStrings; 120 | } 121 | 122 | /** 123 | * Set the line strings 124 | * 125 | * @param lineStrings 126 | * list of line strings 127 | * @since 3.0.0 128 | */ 129 | public void setLineStrings(List lineStrings) { 130 | this.lineStrings = lineStrings; 131 | } 132 | 133 | /** 134 | * Get the simple features multi line string 135 | * 136 | * @return multi line string 137 | * @since 3.0.0 138 | */ 139 | @JsonIgnore 140 | public mil.nga.sf.MultiLineString getMultiLineString() { 141 | List simpleLineStrings = new ArrayList<>(); 142 | for (LineString lineString : lineStrings) { 143 | simpleLineStrings.add(lineString.getLineString()); 144 | } 145 | return new mil.nga.sf.MultiLineString(simpleLineStrings); 146 | } 147 | 148 | /** 149 | * Set the simple features multi line string 150 | * 151 | * @param multiLineString 152 | * multi line string 153 | * @since 3.0.0 154 | */ 155 | public void setMultiLineString(mil.nga.sf.MultiLineString multiLineString) { 156 | lineStrings = new ArrayList<>(); 157 | for (mil.nga.sf.LineString lineString : multiLineString 158 | .getLineStrings()) { 159 | lineStrings.add(new LineString(lineString)); 160 | } 161 | } 162 | 163 | /** 164 | * {@inheritDoc} 165 | */ 166 | @Override 167 | public int hashCode() { 168 | final int prime = 31; 169 | int result = super.hashCode(); 170 | result = prime * result 171 | + ((lineStrings == null) ? 0 : lineStrings.hashCode()); 172 | return result; 173 | } 174 | 175 | /** 176 | * {@inheritDoc} 177 | */ 178 | @Override 179 | public boolean equals(Object obj) { 180 | if (this == obj) 181 | return true; 182 | if (!super.equals(obj)) 183 | return false; 184 | if (getClass() != obj.getClass()) 185 | return false; 186 | MultiLineString other = (MultiLineString) obj; 187 | if (lineStrings == null) { 188 | if (other.lineStrings != null) 189 | return false; 190 | } else if (!lineStrings.equals(other.lineStrings)) 191 | return false; 192 | return true; 193 | } 194 | 195 | } 196 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/geojson/MultiPoint.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.geojson; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import com.fasterxml.jackson.annotation.JsonIgnore; 7 | 8 | /** 9 | * Multi Point 10 | * 11 | * @author yutzlejp 12 | */ 13 | public class MultiPoint extends Geometry { 14 | 15 | /** 16 | * Serialization Version number 17 | */ 18 | private static final long serialVersionUID = 2L; 19 | 20 | /** 21 | * List of points 22 | */ 23 | private List points = null; 24 | 25 | /** 26 | * Create a multi point from coordinates 27 | * 28 | * @param coordinates 29 | * coordinates 30 | * @return multi point 31 | * @since 3.0.0 32 | */ 33 | public static MultiPoint fromCoordinates(List coordinates) { 34 | MultiPoint multiPoint = new MultiPoint(); 35 | multiPoint.setCoordinates(coordinates); 36 | return multiPoint; 37 | } 38 | 39 | /** 40 | * Constructor 41 | */ 42 | public MultiPoint() { 43 | 44 | } 45 | 46 | /** 47 | * Constructor 48 | * 49 | * @param points 50 | * points list 51 | * @since 3.0.0 52 | */ 53 | public MultiPoint(List points) { 54 | this.points = points; 55 | } 56 | 57 | /** 58 | * Constructor 59 | * 60 | * @param multiPoint 61 | * simple multi point 62 | */ 63 | public MultiPoint(mil.nga.sf.MultiPoint multiPoint) { 64 | setMultiPoint(multiPoint); 65 | } 66 | 67 | /** 68 | * {@inheritDoc} 69 | */ 70 | @Override 71 | public GeometryType getGeometryType() { 72 | return GeometryType.MULTIPOINT; 73 | } 74 | 75 | /** 76 | * {@inheritDoc} 77 | */ 78 | @Override 79 | public mil.nga.sf.Geometry getGeometry() { 80 | return getMultiPoint(); 81 | } 82 | 83 | /** 84 | * Returns coordinates as a GeoJSON Position list 85 | * 86 | * @return the coordinates 87 | */ 88 | public List getCoordinates() { 89 | List coordinates = new ArrayList<>(); 90 | for (Point point : points) { 91 | coordinates.add(point.getCoordinates()); 92 | } 93 | return coordinates; 94 | } 95 | 96 | /** 97 | * Sets the coordinates from a GeoJSON Position list 98 | * 99 | * @param coordinates 100 | * coordinates 101 | * @since 3.0.0 102 | */ 103 | public void setCoordinates(List coordinates) { 104 | points = new ArrayList<>(); 105 | for (Position position : coordinates) { 106 | points.add(Point.fromCoordinates(position)); 107 | } 108 | } 109 | 110 | /** 111 | * Get the points 112 | * 113 | * @return list of points 114 | * @since 3.0.0 115 | */ 116 | @JsonIgnore 117 | public List getPoints() { 118 | return points; 119 | } 120 | 121 | /** 122 | * Set the points 123 | * 124 | * @param points 125 | * list of points 126 | * @since 3.0.0 127 | */ 128 | public void setPoints(List points) { 129 | this.points = points; 130 | } 131 | 132 | /** 133 | * Get the simple features multi point 134 | * 135 | * @return multi point 136 | * @since 3.0.0 137 | */ 138 | @JsonIgnore 139 | public mil.nga.sf.MultiPoint getMultiPoint() { 140 | List simplePoints = new ArrayList<>(); 141 | for (Point point : points) { 142 | simplePoints.add(point.getPoint()); 143 | } 144 | return new mil.nga.sf.MultiPoint(simplePoints); 145 | } 146 | 147 | /** 148 | * Set the simple features multi point 149 | * 150 | * @param multiPoint 151 | * multi point 152 | * @since 3.0.0 153 | */ 154 | public void setMultiPoint(mil.nga.sf.MultiPoint multiPoint) { 155 | points = new ArrayList<>(); 156 | for (mil.nga.sf.Point point : multiPoint.getPoints()) { 157 | points.add(new Point(point)); 158 | } 159 | } 160 | 161 | /** 162 | * {@inheritDoc} 163 | */ 164 | @Override 165 | public int hashCode() { 166 | final int prime = 31; 167 | int result = super.hashCode(); 168 | result = prime * result + ((points == null) ? 0 : points.hashCode()); 169 | return result; 170 | } 171 | 172 | /** 173 | * {@inheritDoc} 174 | */ 175 | @Override 176 | public boolean equals(Object obj) { 177 | if (this == obj) 178 | return true; 179 | if (!super.equals(obj)) 180 | return false; 181 | if (getClass() != obj.getClass()) 182 | return false; 183 | MultiPoint other = (MultiPoint) obj; 184 | if (points == null) { 185 | if (other.points != null) 186 | return false; 187 | } else if (!points.equals(other.points)) 188 | return false; 189 | return true; 190 | } 191 | 192 | } 193 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/geojson/MultiPolygon.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.geojson; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import com.fasterxml.jackson.annotation.JsonIgnore; 7 | 8 | /** 9 | * Multi Polygon 10 | * 11 | * @author yutzlejp 12 | */ 13 | public class MultiPolygon extends Geometry { 14 | 15 | /** 16 | * Serialization Version number 17 | */ 18 | private static final long serialVersionUID = 2L; 19 | 20 | /** 21 | * List of polygons 22 | */ 23 | private List polygons = null; 24 | 25 | /** 26 | * Create a multi polygon from coordinates 27 | * 28 | * @param coordinates 29 | * coordinates 30 | * @return multi polygon 31 | * @since 3.0.0 32 | */ 33 | public static MultiPolygon fromCoordinates( 34 | List>> coordinates) { 35 | MultiPolygon multiPolygon = new MultiPolygon(); 36 | multiPolygon.setCoordinates(coordinates); 37 | return multiPolygon; 38 | } 39 | 40 | /** 41 | * Constructor 42 | */ 43 | public MultiPolygon() { 44 | 45 | } 46 | 47 | /** 48 | * Constructor 49 | * 50 | * @param polygons 51 | * polygon list 52 | * @since 3.0.0 53 | */ 54 | public MultiPolygon(List polygons) { 55 | this.polygons = polygons; 56 | } 57 | 58 | /** 59 | * Constructor 60 | * 61 | * @param multiPolygon 62 | * simple multi polygon 63 | */ 64 | public MultiPolygon(mil.nga.sf.MultiPolygon multiPolygon) { 65 | setMultiPolygon(multiPolygon); 66 | } 67 | 68 | /** 69 | * {@inheritDoc} 70 | */ 71 | @Override 72 | public GeometryType getGeometryType() { 73 | return GeometryType.MULTIPOLYGON; 74 | } 75 | 76 | /** 77 | * {@inheritDoc} 78 | */ 79 | @Override 80 | public mil.nga.sf.Geometry getGeometry() { 81 | return getMultiPolygon(); 82 | } 83 | 84 | /** 85 | * Returns coordinates as a GeoJSON Position list 86 | * 87 | * @return the coordinates 88 | */ 89 | public List>> getCoordinates() { 90 | List>> coordinates = new ArrayList<>(); 91 | for (Polygon polygon : polygons) { 92 | coordinates.add(polygon.getCoordinates()); 93 | } 94 | return coordinates; 95 | } 96 | 97 | /** 98 | * Sets the coordinates from a GeoJSON Position list 99 | * 100 | * @param coordinates 101 | * coordinates 102 | * @since 3.0.0 103 | */ 104 | public void setCoordinates(List>> coordinates) { 105 | polygons = new ArrayList<>(); 106 | for (List> positions : coordinates) { 107 | polygons.add(Polygon.fromCoordinates(positions)); 108 | } 109 | } 110 | 111 | /** 112 | * Get the polygons 113 | * 114 | * @return list of polygons 115 | * @since 3.0.0 116 | */ 117 | @JsonIgnore 118 | public List getPolygons() { 119 | return polygons; 120 | } 121 | 122 | /** 123 | * Set the polygons 124 | * 125 | * @param polygons 126 | * list of polygons 127 | * @since 3.0.0 128 | */ 129 | public void setPolygons(List polygons) { 130 | this.polygons = polygons; 131 | } 132 | 133 | /** 134 | * Get the simple features multi polygon 135 | * 136 | * @return multi polygon 137 | * @since 3.0.0 138 | */ 139 | @JsonIgnore 140 | public mil.nga.sf.MultiPolygon getMultiPolygon() { 141 | List simplePolygons = new ArrayList<>(); 142 | for (Polygon polygon : polygons) { 143 | simplePolygons.add(polygon.getPolygon()); 144 | } 145 | return new mil.nga.sf.MultiPolygon(simplePolygons); 146 | } 147 | 148 | /** 149 | * Set the simple features multi polygon 150 | * 151 | * @param multiPolygon 152 | * multi polygon 153 | * @since 3.0.0 154 | */ 155 | public void setMultiPolygon(mil.nga.sf.MultiPolygon multiPolygon) { 156 | polygons = new ArrayList<>(); 157 | for (mil.nga.sf.Polygon polygon : multiPolygon.getPolygons()) { 158 | polygons.add(new Polygon(polygon)); 159 | } 160 | } 161 | 162 | /** 163 | * {@inheritDoc} 164 | */ 165 | @Override 166 | public int hashCode() { 167 | final int prime = 31; 168 | int result = super.hashCode(); 169 | result = prime * result 170 | + ((polygons == null) ? 0 : polygons.hashCode()); 171 | return result; 172 | } 173 | 174 | /** 175 | * {@inheritDoc} 176 | */ 177 | @Override 178 | public boolean equals(Object obj) { 179 | if (this == obj) 180 | return true; 181 | if (!super.equals(obj)) 182 | return false; 183 | if (getClass() != obj.getClass()) 184 | return false; 185 | MultiPolygon other = (MultiPolygon) obj; 186 | if (polygons == null) { 187 | if (other.polygons != null) 188 | return false; 189 | } else if (!polygons.equals(other.polygons)) 190 | return false; 191 | return true; 192 | } 193 | 194 | } 195 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/geojson/Point.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.geojson; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | 5 | /** 6 | * Point 7 | * 8 | * @author yutzlejp 9 | */ 10 | public class Point extends Geometry { 11 | 12 | /** 13 | * Serialization Version number 14 | */ 15 | private static final long serialVersionUID = 2L; 16 | 17 | /** 18 | * Position 19 | */ 20 | private Position position; 21 | 22 | /** 23 | * Create a point from coordinates 24 | * 25 | * @param coordinates 26 | * coordinates 27 | * @return point 28 | * @since 3.0.0 29 | */ 30 | public static Point fromCoordinates(Position coordinates) { 31 | return new Point(coordinates); 32 | } 33 | 34 | /** 35 | * Constructor 36 | */ 37 | public Point() { 38 | 39 | } 40 | 41 | /** 42 | * Constructor 43 | * 44 | * @param position 45 | * position 46 | */ 47 | public Point(Position position) { 48 | this.position = position; 49 | } 50 | 51 | /** 52 | * Constructor 53 | * 54 | * @param point 55 | * simple point 56 | */ 57 | public Point(mil.nga.sf.Point point) { 58 | setPoint(point); 59 | } 60 | 61 | /** 62 | * {@inheritDoc} 63 | */ 64 | @Override 65 | public GeometryType getGeometryType() { 66 | return GeometryType.POINT; 67 | } 68 | 69 | /** 70 | * {@inheritDoc} 71 | */ 72 | @Override 73 | public mil.nga.sf.Geometry getGeometry() { 74 | return getPoint(); 75 | } 76 | 77 | /** 78 | * Returns coordinates as a GeoJSON Position object 79 | * 80 | * @return the coordinates 81 | */ 82 | public Position getCoordinates() { 83 | return getPosition(); 84 | } 85 | 86 | /** 87 | * Sets the coordinates 88 | * 89 | * @param coordinates 90 | * coordinates 91 | */ 92 | public void setCoordinates(Position coordinates) { 93 | setPosition(coordinates); 94 | } 95 | 96 | /** 97 | * Get the position 98 | * 99 | * @return position 100 | * @since 3.0.0 101 | */ 102 | @JsonIgnore 103 | public Position getPosition() { 104 | return position; 105 | } 106 | 107 | /** 108 | * Set the position 109 | * 110 | * @param position 111 | * position 112 | * @since 3.0.0 113 | */ 114 | public void setPosition(Position position) { 115 | this.position = position; 116 | } 117 | 118 | /** 119 | * Get the simple features point 120 | * 121 | * @return point 122 | * @since 3.0.0 123 | */ 124 | @JsonIgnore 125 | public mil.nga.sf.Point getPoint() { 126 | return position.toSimplePoint(); 127 | } 128 | 129 | /** 130 | * Set the simple features point 131 | * 132 | * @param point 133 | * point 134 | * @since 3.0.0 135 | */ 136 | public void setPoint(mil.nga.sf.Point point) { 137 | position = new Position(point); 138 | } 139 | 140 | /** 141 | * {@inheritDoc} 142 | */ 143 | @Override 144 | public int hashCode() { 145 | final int prime = 31; 146 | int result = super.hashCode(); 147 | result = prime * result 148 | + ((position == null) ? 0 : position.hashCode()); 149 | return result; 150 | } 151 | 152 | /** 153 | * {@inheritDoc} 154 | */ 155 | @Override 156 | public boolean equals(Object obj) { 157 | if (this == obj) 158 | return true; 159 | if (!super.equals(obj)) 160 | return false; 161 | if (getClass() != obj.getClass()) 162 | return false; 163 | Point other = (Point) obj; 164 | if (position == null) { 165 | if (other.position != null) 166 | return false; 167 | } else if (!position.equals(other.position)) 168 | return false; 169 | return true; 170 | } 171 | 172 | } 173 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/geojson/Polygon.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.geojson; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import com.fasterxml.jackson.annotation.JsonIgnore; 7 | 8 | import mil.nga.sf.LinearRing; 9 | 10 | /** 11 | * Polygon 12 | * 13 | * @author yutzlejp 14 | */ 15 | public class Polygon extends Geometry { 16 | 17 | /** 18 | * Serialization Version number 19 | */ 20 | private static final long serialVersionUID = 2L; 21 | 22 | /** 23 | * List of line string rings 24 | */ 25 | private List rings = null; 26 | 27 | /** 28 | * Create a polygon from coordinates 29 | * 30 | * @param coordinates 31 | * coordinates 32 | * @return polygon 33 | * @since 3.0.0 34 | */ 35 | public static Polygon fromCoordinates(List> coordinates) { 36 | Polygon polygon = new Polygon(); 37 | polygon.setCoordinates(coordinates); 38 | return polygon; 39 | } 40 | 41 | /** 42 | * Constructor 43 | */ 44 | public Polygon() { 45 | 46 | } 47 | 48 | /** 49 | * Constructor 50 | * 51 | * @param rings 52 | * ring line string list 53 | * @since 3.0.0 54 | */ 55 | public Polygon(List rings) { 56 | this.rings = rings; 57 | } 58 | 59 | /** 60 | * Constructor 61 | * 62 | * @param polygon 63 | * simple polygon 64 | */ 65 | public Polygon(mil.nga.sf.Polygon polygon) { 66 | setPolygon(polygon); 67 | } 68 | 69 | /** 70 | * {@inheritDoc} 71 | */ 72 | @Override 73 | public GeometryType getGeometryType() { 74 | return GeometryType.POLYGON; 75 | } 76 | 77 | /** 78 | * {@inheritDoc} 79 | */ 80 | @Override 81 | public mil.nga.sf.Geometry getGeometry() { 82 | return getPolygon(); 83 | } 84 | 85 | /** 86 | * Returns coordinates as a GeoJSON Position list 87 | * 88 | * @return the coordinates 89 | */ 90 | public List> getCoordinates() { 91 | List> coordinates = new ArrayList<>(); 92 | for (LineString ring : rings) { 93 | coordinates.add(ring.getCoordinates()); 94 | } 95 | return coordinates; 96 | } 97 | 98 | /** 99 | * Sets the coordinates from a GeoJSON Position list 100 | * 101 | * @param coordinates 102 | * coordinates 103 | * @since 3.0.0 104 | */ 105 | public void setCoordinates(List> coordinates) { 106 | rings = new ArrayList<>(); 107 | for (List positions : coordinates) { 108 | rings.add(LineString.fromCoordinates(positions)); 109 | } 110 | } 111 | 112 | /** 113 | * Get the rings 114 | * 115 | * @return list of ring line strings 116 | * @since 3.0.0 117 | */ 118 | @JsonIgnore 119 | public List getRings() { 120 | return rings; 121 | } 122 | 123 | /** 124 | * Set the rings 125 | * 126 | * @param rings 127 | * list of ring line strings 128 | * @since 3.0.0 129 | */ 130 | public void setRings(List rings) { 131 | this.rings = rings; 132 | } 133 | 134 | /** 135 | * Get the simple features polygon 136 | * 137 | * @return polygon 138 | * @since 3.0.0 139 | */ 140 | @JsonIgnore 141 | public mil.nga.sf.Polygon getPolygon() { 142 | mil.nga.sf.Polygon polygon = new mil.nga.sf.Polygon(); 143 | for (LineString ring : rings) { 144 | polygon.addRing(new LinearRing(ring.getLineString().getPoints())); 145 | } 146 | return polygon; 147 | } 148 | 149 | /** 150 | * Set the simple features polygon 151 | * 152 | * @param polygon 153 | * polygon 154 | * @since 3.0.0 155 | */ 156 | public void setPolygon(mil.nga.sf.Polygon polygon) { 157 | rings = new ArrayList<>(); 158 | for (mil.nga.sf.LineString ring : polygon.getRings()) { 159 | rings.add(new LineString(ring)); 160 | } 161 | } 162 | 163 | /** 164 | * {@inheritDoc} 165 | */ 166 | @Override 167 | public int hashCode() { 168 | final int prime = 31; 169 | int result = super.hashCode(); 170 | result = prime * result + ((rings == null) ? 0 : rings.hashCode()); 171 | return result; 172 | } 173 | 174 | /** 175 | * {@inheritDoc} 176 | */ 177 | @Override 178 | public boolean equals(Object obj) { 179 | if (this == obj) 180 | return true; 181 | if (!super.equals(obj)) 182 | return false; 183 | if (getClass() != obj.getClass()) 184 | return false; 185 | Polygon other = (Polygon) obj; 186 | if (rings == null) { 187 | if (other.rings != null) 188 | return false; 189 | } else if (!rings.equals(other.rings)) 190 | return false; 191 | return true; 192 | } 193 | 194 | } 195 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/geojson/Position.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.geojson; 2 | 3 | import java.io.Serializable; 4 | import java.util.ArrayList; 5 | import java.util.Arrays; 6 | import java.util.List; 7 | 8 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 9 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 10 | 11 | import mil.nga.sf.geojson.jackson.CoordinatesDeserializer; 12 | import mil.nga.sf.geojson.jackson.CoordinatesSerializer; 13 | 14 | /** 15 | * Position 16 | * 17 | * @author yutzlejp 18 | */ 19 | @JsonDeserialize(using = CoordinatesDeserializer.class) 20 | @JsonSerialize(using = CoordinatesSerializer.class) 21 | public class Position implements Serializable { 22 | 23 | /** 24 | * Serialization Version number 25 | */ 26 | private static final long serialVersionUID = 1L; 27 | 28 | /** 29 | * Coordinate values 30 | */ 31 | private final double[] coordinates; 32 | 33 | /** 34 | * Additional coordinate values beyond long, lat, and altitude, such as m 35 | */ 36 | private final List additionalElements; 37 | 38 | /** 39 | * Constructor 40 | * 41 | * @param point 42 | * simple point 43 | */ 44 | public Position(mil.nga.sf.Point point) { 45 | this(point.getX(), point.getY(), point.getZ(), point.getM()); 46 | } 47 | 48 | /** 49 | * Constructor 50 | * 51 | * @param longitude 52 | * longitude value 53 | * @param latitude 54 | * latitude value 55 | */ 56 | public Position(Double longitude, Double latitude) { 57 | this(longitude, latitude, null); 58 | } 59 | 60 | /** 61 | * Construct a Coordinates with additional elements. The specification 62 | * allows for any number of additional elements in a position, after lng, 63 | * lat, alt. https://tools.ietf.org/html/rfc7946#section-3.1.1 64 | * 65 | * @param longitude 66 | * The longitude. 67 | * @param latitude 68 | * The latitude. 69 | * @param altitude 70 | * The altitude. 71 | * @param additionalElements 72 | * The additional elements. 73 | */ 74 | public Position(Double longitude, Double latitude, Double altitude, 75 | Double... additionalElements) { 76 | if ((longitude == null) || (latitude == null)) { 77 | coordinates = new double[0]; 78 | this.additionalElements = new ArrayList<>(); 79 | } else if (altitude == null) { 80 | coordinates = new double[] { longitude, latitude }; 81 | this.additionalElements = new ArrayList<>(); 82 | } else { 83 | coordinates = new double[] { longitude, latitude, altitude }; 84 | 85 | if (additionalElementsPresent(additionalElements)) { 86 | this.additionalElements = Arrays.asList(additionalElements); 87 | 88 | for (Double element : this.additionalElements) { 89 | if (Double.isNaN(element)) { 90 | throw new IllegalArgumentException( 91 | "No additional elements may be NaN."); 92 | } 93 | if (Double.isInfinite(element)) { 94 | throw new IllegalArgumentException( 95 | "No additional elements may be infinite."); 96 | } 97 | } 98 | } else { 99 | this.additionalElements = new ArrayList<>(); 100 | } 101 | } 102 | 103 | checkAltitudeAndAdditionalElements(); 104 | } 105 | 106 | /** 107 | * Check if the position has additional elements 108 | * 109 | * @return true if additional elements 110 | */ 111 | public boolean hasAdditionalElements() { 112 | return !additionalElements.isEmpty(); 113 | } 114 | 115 | /** 116 | * Get the additional elements 117 | * 118 | * @return additional elements 119 | */ 120 | public List getAdditionalElements() { 121 | return additionalElements; 122 | } 123 | 124 | /** 125 | * Verify altitude is present if additional elements were provided 126 | */ 127 | private void checkAltitudeAndAdditionalElements() { 128 | if ((this.getZ() == null) && hasAdditionalElements()) { 129 | throw new IllegalArgumentException( 130 | "Additional Elements are only valid if Altitude is also provided."); 131 | } 132 | } 133 | 134 | /** 135 | * Check if additional elements are present 136 | * 137 | * @param additionalElements 138 | * additional elements 139 | * @return true if contains additional elements 140 | */ 141 | private static boolean additionalElementsPresent( 142 | Double[] additionalElements) { 143 | return (additionalElements.length > 0) 144 | && (additionalElements[0] != null); 145 | } 146 | 147 | /** 148 | * Get the x value 149 | * 150 | * @return x 151 | */ 152 | public Double getX() { 153 | return coordinates.length > 0 ? coordinates[0] : null; 154 | } 155 | 156 | /** 157 | * Get the y value 158 | * 159 | * @return y 160 | */ 161 | public Double getY() { 162 | return coordinates.length > 1 ? coordinates[1] : null; 163 | } 164 | 165 | /** 166 | * Get the z value 167 | * 168 | * @return z 169 | */ 170 | public Double getZ() { 171 | return hasZ() ? coordinates[2] : null; 172 | } 173 | 174 | /** 175 | * Get the m value 176 | * 177 | * @return m 178 | */ 179 | public Double getM() { 180 | return hasM() ? additionalElements.get(0) : null; 181 | } 182 | 183 | /** 184 | * Check if position has a z value 185 | * 186 | * @return true if has z value 187 | */ 188 | public boolean hasZ() { 189 | return coordinates.length > 2; 190 | } 191 | 192 | /** 193 | * Check if position has a m value 194 | * 195 | * @return true if has m value 196 | */ 197 | public boolean hasM() { 198 | return additionalElements.size() > 0; 199 | } 200 | 201 | /** 202 | * Convert to simple point 203 | * 204 | * @return simple point 205 | */ 206 | public mil.nga.sf.Point toSimplePoint() { 207 | mil.nga.sf.Point point = null; 208 | Double x = getX(); 209 | Double y = getY(); 210 | if (x != null && y != null) { 211 | point = new mil.nga.sf.Point(x, y, getZ(), getM()); 212 | } 213 | return point; 214 | } 215 | 216 | /** 217 | * {@inheritDoc} 218 | */ 219 | @Override 220 | public int hashCode() { 221 | final int prime = 31; 222 | int result = 1; 223 | result = prime * result + ((additionalElements == null) ? 0 224 | : additionalElements.hashCode()); 225 | result = prime * result + Arrays.hashCode(coordinates); 226 | return result; 227 | } 228 | 229 | /** 230 | * {@inheritDoc} 231 | */ 232 | @Override 233 | public boolean equals(Object obj) { 234 | if (this == obj) 235 | return true; 236 | if (obj == null) 237 | return false; 238 | if (getClass() != obj.getClass()) 239 | return false; 240 | Position other = (Position) obj; 241 | if (additionalElements == null) { 242 | if (other.additionalElements != null) 243 | return false; 244 | } else if (!additionalElements.equals(other.additionalElements)) 245 | return false; 246 | if (!Arrays.equals(coordinates, other.coordinates)) 247 | return false; 248 | return true; 249 | } 250 | 251 | } 252 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/geojson/jackson/CoordinatesDeserializer.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.geojson.jackson; 2 | 3 | import java.io.IOException; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | import mil.nga.sf.geojson.Position; 8 | 9 | import com.fasterxml.jackson.core.JsonParseException; 10 | import com.fasterxml.jackson.core.JsonParser; 11 | import com.fasterxml.jackson.core.JsonProcessingException; 12 | import com.fasterxml.jackson.core.JsonToken; 13 | import com.fasterxml.jackson.databind.DeserializationContext; 14 | import com.fasterxml.jackson.databind.JsonDeserializer; 15 | 16 | /** 17 | * Coordinates Deserializer 18 | * 19 | * @author yutzlejp 20 | */ 21 | public class CoordinatesDeserializer extends JsonDeserializer { 22 | 23 | /** 24 | * {@inheritDoc} 25 | */ 26 | @Override 27 | public Position deserialize(JsonParser jp, DeserializationContext ctxt) 28 | throws IOException, JsonProcessingException { 29 | if (jp.isExpectedStartArrayToken()) { 30 | return deserializeArray(jp, ctxt); 31 | } 32 | ctxt.reportWrongTokenException(this, JsonToken.START_ARRAY, 33 | "Unexpected token when binding data into Position"); 34 | return null; 35 | } 36 | 37 | /** 38 | * Deserialize array 39 | * 40 | * @param jp 41 | * json parser 42 | * @param ctxt 43 | * context 44 | * @return position 45 | * @throws IOException upon error 46 | * @throws JsonProcessingException upon error 47 | */ 48 | protected Position deserializeArray(JsonParser jp, 49 | DeserializationContext ctxt) throws IOException, 50 | JsonProcessingException { 51 | 52 | Double x = extractDouble(jp, ctxt, false); 53 | Double y = extractDouble(jp, ctxt, false); 54 | Double z = extractDouble(jp, ctxt, true); 55 | 56 | List additionalElements = new ArrayList<>(); 57 | while (jp.hasCurrentToken() 58 | && jp.getCurrentToken() != JsonToken.END_ARRAY) { 59 | Double element = extractDouble(jp, ctxt, true); 60 | if (!(element == null)) { 61 | additionalElements.add(element); 62 | } 63 | } 64 | 65 | Double[] aeArray = new Double[additionalElements.size()]; 66 | 67 | return new Position(x, y, z, additionalElements.toArray(aeArray)); 68 | } 69 | 70 | /** 71 | * Extract double 72 | * 73 | * @param jp 74 | * json parser 75 | * @param ctxt 76 | * context 77 | * @param optional 78 | * true if optional 79 | * @return double value 80 | * @throws JsonParseException 81 | * @throws IOException 82 | */ 83 | private Double extractDouble(JsonParser jp, DeserializationContext ctxt, 84 | boolean optional) throws JsonParseException, IOException { 85 | JsonToken token = jp.nextToken(); 86 | if (token == null) { 87 | if (!optional) { 88 | ctxt.reportWrongTokenException(this, 89 | JsonToken.VALUE_NUMBER_FLOAT, 90 | "Unexpected end-of-input when binding data into Coordinates"); 91 | } 92 | return null; 93 | } else { 94 | switch (token) { 95 | case END_ARRAY: 96 | if (!optional) { 97 | ctxt.reportWrongTokenException(this, 98 | JsonToken.VALUE_NUMBER_FLOAT, 99 | "Unexpected end-of-input when binding data into Coordinates"); 100 | } 101 | return null; 102 | case VALUE_NUMBER_FLOAT: 103 | return jp.getDoubleValue(); 104 | case VALUE_NUMBER_INT: 105 | return Double.valueOf(jp.getLongValue()); 106 | case VALUE_STRING: 107 | return jp.getValueAsDouble(); 108 | default: 109 | ctxt.reportWrongTokenException( 110 | this, 111 | JsonToken.VALUE_NUMBER_FLOAT, 112 | "Unexpected token (%s) when binding data into LngLatAlt", 113 | token.name()); 114 | return null; 115 | } 116 | } 117 | } 118 | 119 | } 120 | -------------------------------------------------------------------------------- /src/main/java/mil/nga/sf/geojson/jackson/CoordinatesSerializer.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.geojson.jackson; 2 | 3 | import java.io.IOException; 4 | 5 | import mil.nga.sf.geojson.Position; 6 | 7 | import com.fasterxml.jackson.core.JsonGenerator; 8 | import com.fasterxml.jackson.core.JsonProcessingException; 9 | import com.fasterxml.jackson.databind.JsonSerializer; 10 | import com.fasterxml.jackson.databind.SerializerProvider; 11 | 12 | /** 13 | * Coordinates Serializer 14 | * 15 | * @author yutzlejp 16 | */ 17 | public class CoordinatesSerializer extends JsonSerializer { 18 | 19 | /** 20 | * {@inheritDoc} 21 | */ 22 | @Override 23 | public void serialize(Position value, JsonGenerator jgen, 24 | SerializerProvider provider) throws IOException, 25 | JsonProcessingException { 26 | jgen.writeStartArray(); 27 | jgen.writeNumber(value.getX()); 28 | jgen.writeNumber(value.getY()); 29 | Double alt = value.getZ(); 30 | if (alt != null) { 31 | jgen.writeNumber(alt); 32 | 33 | for (double d : value.getAdditionalElements()) { 34 | jgen.writeNumber(d); 35 | } 36 | } 37 | jgen.writeEndArray(); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/test/java/mil/nga/sf/geojson/FeatureTest.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.geojson; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertFalse; 5 | import static org.junit.Assert.assertNotNull; 6 | import static org.junit.Assert.assertTrue; 7 | 8 | import java.util.Map; 9 | 10 | import org.junit.Test; 11 | 12 | import com.fasterxml.jackson.databind.JsonNode; 13 | import com.fasterxml.jackson.databind.node.ObjectNode; 14 | 15 | import mil.nga.sf.Geometry; 16 | 17 | public class FeatureTest { 18 | 19 | @Test 20 | public void itShouldSerializeFeature() throws Exception { 21 | Feature testObject = new Feature(); 22 | 23 | // http://geojson.org/geojson-spec.html#feature-objects 24 | // A feature object must have a member with the name "properties". 25 | // The value of the properties member is an object (any JSON object or a 26 | // JSON null value). 27 | assertNotNull(testObject.getProperties()); 28 | 29 | JsonNode nodeFromPojo = TestUtils.getMapper().valueToTree(testObject); 30 | JsonNode nodeFromString = TestUtils.getMapper() 31 | .readTree("{\"type\":\"Feature\",\"geometry\":null}"); 32 | ((ObjectNode) nodeFromString).set("properties", 33 | TestUtils.getMapper().createObjectNode()); 34 | assertEquals(nodeFromPojo, nodeFromString); 35 | } 36 | 37 | @Test 38 | public void itShouldSerializeFeature2() throws Exception { 39 | 40 | Feature feature = getTestFeature(); 41 | 42 | feature.getProperties().put("foo", "bar"); 43 | 44 | JsonNode nodeFromPojo = TestUtils.getMapper().valueToTree(feature); 45 | JsonNode nodeFromString = TestUtils.getMapper().readTree( 46 | "{\"type\":\"Feature\",\"properties\":{\"foo\":\"bar\"},\"geometry\":{\"type\":\"MultiPolygon\",\"coordinates\":[[[[-100.0,-50.0],[100.0,-50.0],[1.0,50.0],[-100.0,-50.0]],[[-50.0,-25.0],[50.0,-25.0],[-1.0,25.0],[-50.0,-25.0]]]]}}"); 47 | assertEquals(nodeFromPojo, nodeFromString); 48 | } 49 | 50 | @Test 51 | public void itShouldDeserializeFeature() throws Exception { 52 | GeoJsonObject value = TestUtils.getMapper().readValue( 53 | "{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[100.0,5.0]},\"properties\":{}}", 54 | GeoJsonObject.class); 55 | assertNotNull(value); 56 | assertTrue(value instanceof Feature); 57 | Feature feature = (Feature) value; 58 | assertNotNull(feature.getSimpleGeometry()); 59 | Object geometryO = feature.getSimpleGeometry(); 60 | assertTrue(geometryO instanceof mil.nga.sf.Point); 61 | mil.nga.sf.Point simplePoint = (mil.nga.sf.Point) geometryO; 62 | TestUtils.assertPoint(100d, 5d, null, 63 | (Point) FeatureConverter.toGeometry(simplePoint)); 64 | } 65 | 66 | @Test 67 | public void itShouldDeserializeFeatureWithProperty() throws Exception { 68 | GeoJsonObject value = TestUtils.getMapper().readValue( 69 | "{\"type\":\"Feature\",\"geometry\":null,\"properties\":{\"foo\":\"bar\"}}", 70 | GeoJsonObject.class); 71 | assertNotNull(value); 72 | assertTrue(value instanceof Feature); 73 | Feature feature = (Feature) value; 74 | assertTrue(null == feature.getSimpleGeometry()); 75 | Map map = feature.getProperties(); 76 | assertTrue(map.containsKey("foo")); 77 | assertEquals("bar", map.get("foo")); 78 | } 79 | 80 | @Test 81 | public void toMap() { 82 | 83 | Feature feature = getTestFeature(); 84 | 85 | Map map = FeatureConverter.toMap(feature); 86 | assertNotNull(map); 87 | assertFalse(map.isEmpty()); 88 | 89 | Feature featureFromMap = FeatureConverter.toFeature(map); 90 | assertNotNull(featureFromMap); 91 | 92 | assertEquals(feature, featureFromMap); 93 | assertEquals(feature.getSimpleGeometry(), 94 | featureFromMap.getSimpleGeometry()); 95 | 96 | GeoJsonObject geoJsonObjectFromString = FeatureConverter 97 | .toGeoJsonObject(map); 98 | assertNotNull(geoJsonObjectFromString); 99 | assertTrue(geoJsonObjectFromString instanceof Feature); 100 | 101 | Feature featureGeoJsonObject = (Feature) geoJsonObjectFromString; 102 | assertEquals(feature, featureGeoJsonObject); 103 | assertEquals(feature.getSimpleGeometry(), 104 | featureGeoJsonObject.getSimpleGeometry()); 105 | } 106 | 107 | @Test 108 | public void toGeometry() { 109 | 110 | mil.nga.sf.Geometry simpleGeometry = TestUtils 111 | .getMultiPolygonWithRings(); 112 | 113 | Feature feature = FeatureConverter.toFeature(simpleGeometry); 114 | assertNotNull(feature); 115 | 116 | assertEquals(simpleGeometry, feature.getSimpleGeometry()); 117 | } 118 | 119 | @Test 120 | public void toStringValue() { 121 | 122 | Feature feature = getTestFeature(); 123 | 124 | String stringValue = FeatureConverter.toStringValue(feature); 125 | assertNotNull(stringValue); 126 | assertFalse(stringValue.isEmpty()); 127 | 128 | Feature featureFromString = FeatureConverter.toFeature(stringValue); 129 | assertNotNull(featureFromString); 130 | 131 | assertEquals(feature, featureFromString); 132 | assertEquals(feature.getSimpleGeometry(), 133 | featureFromString.getSimpleGeometry()); 134 | 135 | GeoJsonObject geoJsonObjectFromString = FeatureConverter 136 | .toGeoJsonObject(stringValue); 137 | assertNotNull(geoJsonObjectFromString); 138 | assertTrue(geoJsonObjectFromString instanceof Feature); 139 | 140 | Feature featureGeoJsonObject = (Feature) geoJsonObjectFromString; 141 | assertEquals(feature, featureGeoJsonObject); 142 | assertEquals(feature.getSimpleGeometry(), 143 | featureGeoJsonObject.getSimpleGeometry()); 144 | 145 | Geometry geometry = FeatureConverter.toSimpleGeometry(stringValue); 146 | assertEquals(geoJsonObjectFromString.getSimpleGeometry(), geometry); 147 | assertEquals(feature.getSimpleGeometry(), geometry); 148 | 149 | } 150 | 151 | private Feature getTestFeature() { 152 | 153 | mil.nga.sf.Geometry geometry = TestUtils.getMultiPolygonWithRings(); 154 | Feature feature = FeatureConverter.toFeature(geometry); 155 | 156 | return feature; 157 | } 158 | 159 | } -------------------------------------------------------------------------------- /src/test/java/mil/nga/sf/geojson/GeometryCollectionTest.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.geojson; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertNotNull; 5 | import static org.junit.Assert.assertTrue; 6 | 7 | import java.util.List; 8 | 9 | import org.junit.Test; 10 | 11 | import mil.nga.sf.Geometry; 12 | import mil.nga.sf.LineString; 13 | 14 | public class GeometryCollectionTest { 15 | 16 | private static String GEOMETRYCOLLECTION = "{\"type\":\"GeometryCollection\",\"geometries\":[{\"type\":\"Point\",\"coordinates\":[61.34765625,48.63290858589535]},{\"type\":\"LineString\",\"coordinates\":[[100.0,10.0],[101.0,1.0]]}]}"; 17 | private static String GEOMETRYCOLLECTION_WITH_ALT = "{\"type\":\"GeometryCollection\",\"geometries\":[{\"type\":\"Point\",\"coordinates\":[61.34765625,48.63290858589535, 12.7843]},{\"type\":\"LineString\",\"coordinates\":[[100.0,10.0,5.0],[101.0,1.0,10.0]]}]}"; 18 | 19 | @Test 20 | public void itShouldSerializeSFGeometryCollection() throws Exception { 21 | Geometry geometryCollection = getTestGeometry(); 22 | TestUtils.compareAsNodes(geometryCollection, GEOMETRYCOLLECTION); 23 | } 24 | 25 | @Test 26 | public void itShouldSerializeSFGeometryCollectionWithAltitude() 27 | throws Exception { 28 | mil.nga.sf.GeometryCollection geometryCollection = new mil.nga.sf.GeometryCollection<>(); 29 | mil.nga.sf.Point point = new mil.nga.sf.Point(61.34765625, 30 | 48.63290858589535, 12.7843); 31 | geometryCollection.addGeometry(point); 32 | LineString lineString = new LineString(); 33 | lineString.addPoint(new mil.nga.sf.Point(100.0, 10.0, 5.0)); 34 | lineString.addPoint(new mil.nga.sf.Point(101.0, 1.0, 10.0)); 35 | geometryCollection.addGeometry(lineString); 36 | TestUtils.compareAsNodes(geometryCollection, 37 | GEOMETRYCOLLECTION_WITH_ALT); 38 | } 39 | 40 | @Test 41 | public void itShouldDeserializeGeometryCollection() throws Exception { 42 | GeoJsonObject value = TestUtils.getMapper() 43 | .readValue(GEOMETRYCOLLECTION, GeoJsonObject.class); 44 | assertNotNull(value); 45 | assertTrue(value instanceof GeometryCollection); 46 | GeometryCollection gjGeometryCollection = (GeometryCollection) value; 47 | mil.nga.sf.Geometry geometry = gjGeometryCollection.getGeometry(); 48 | assertTrue(geometry instanceof mil.nga.sf.GeometryCollection); 49 | @SuppressWarnings("unchecked") 50 | mil.nga.sf.GeometryCollection geometryCollection = (mil.nga.sf.GeometryCollection) geometry; 51 | List geometries = geometryCollection 52 | .getGeometries(); 53 | assertTrue(geometries.size() == 2); 54 | mil.nga.sf.Geometry geometry1 = geometries.get(0); 55 | assertTrue(geometry1 instanceof mil.nga.sf.Point); 56 | mil.nga.sf.Point point = (mil.nga.sf.Point) geometry1; 57 | assertEquals(new mil.nga.sf.Point(61.34765625, 48.63290858589535), 58 | point); 59 | mil.nga.sf.Geometry geometry2 = geometries.get(1); 60 | assertTrue(geometry2 instanceof mil.nga.sf.LineString); 61 | mil.nga.sf.LineString lineString = (mil.nga.sf.LineString) geometry2; 62 | assertEquals(new mil.nga.sf.Point(100.0, 10.0), lineString.getPoint(0)); 63 | assertEquals(new mil.nga.sf.Point(101.0, 1.0), lineString.getPoint(1)); 64 | } 65 | 66 | @Test 67 | public void itShouldDeserializeGeometryCollectionWithAltitude() 68 | throws Exception { 69 | GeoJsonObject value = TestUtils.getMapper() 70 | .readValue(GEOMETRYCOLLECTION_WITH_ALT, GeoJsonObject.class); 71 | assertNotNull(value); 72 | assertTrue(value instanceof GeometryCollection); 73 | GeometryCollection gjGeometryCollection = (GeometryCollection) value; 74 | mil.nga.sf.Geometry geometry = gjGeometryCollection.getGeometry(); 75 | assertTrue(geometry instanceof mil.nga.sf.GeometryCollection); 76 | @SuppressWarnings("unchecked") 77 | mil.nga.sf.GeometryCollection geometryCollection = (mil.nga.sf.GeometryCollection) geometry; 78 | List geometries = geometryCollection 79 | .getGeometries(); 80 | assertTrue(geometries.size() == 2); 81 | mil.nga.sf.Geometry geometry1 = geometries.get(0); 82 | assertTrue(geometry1 instanceof mil.nga.sf.Point); 83 | mil.nga.sf.Point point = (mil.nga.sf.Point) geometry1; 84 | assertEquals( 85 | new mil.nga.sf.Point(61.34765625, 48.63290858589535, 12.7843), 86 | point); 87 | mil.nga.sf.Geometry geometry2 = geometries.get(1); 88 | assertTrue(geometry2 instanceof mil.nga.sf.LineString); 89 | mil.nga.sf.LineString lineString = (mil.nga.sf.LineString) geometry2; 90 | assertEquals(new mil.nga.sf.Point(100.0, 10.0, 5.0), 91 | lineString.getPoint(0)); 92 | assertEquals(new mil.nga.sf.Point(101.0, 1.0, 10.0), 93 | lineString.getPoint(1)); 94 | } 95 | 96 | @Test 97 | public void toGeometry() { 98 | TestUtils.toGeometry(getTestGeometry()); 99 | } 100 | 101 | @Test 102 | public void toMap() { 103 | TestUtils.toMap(getTestGeometry()); 104 | } 105 | 106 | @Test 107 | public void toStringValue() { 108 | TestUtils.toStringValue(getTestGeometry()); 109 | } 110 | 111 | private mil.nga.sf.Geometry getTestGeometry() { 112 | 113 | mil.nga.sf.GeometryCollection geometryCollection = new mil.nga.sf.GeometryCollection<>(); 114 | mil.nga.sf.Point point = new mil.nga.sf.Point(61.34765625, 115 | 48.63290858589535); 116 | geometryCollection.addGeometry(point); 117 | LineString lineString = new LineString(); 118 | lineString.addPoint(new mil.nga.sf.Point(100.0, 10.0)); 119 | lineString.addPoint(new mil.nga.sf.Point(101.0, 1.0)); 120 | geometryCollection.addGeometry(lineString); 121 | 122 | return geometryCollection; 123 | } 124 | 125 | } 126 | -------------------------------------------------------------------------------- /src/test/java/mil/nga/sf/geojson/LineStringTest.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.geojson; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertNotNull; 5 | import static org.junit.Assert.assertTrue; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | import org.junit.Test; 11 | 12 | public class LineStringTest { 13 | 14 | @Test 15 | public void itShouldSerializeSFLineString() throws Exception { 16 | List points = new ArrayList<>(); 17 | points.add(new mil.nga.sf.Point(100d, 10d)); 18 | points.add(new mil.nga.sf.Point(101d, 1d)); 19 | mil.nga.sf.LineString lineString = new mil.nga.sf.LineString(points); 20 | TestUtils.compareAsNodes(lineString, 21 | "{\"type\":\"LineString\",\"coordinates\":[[100.0,10.0],[101.0,1.0]]}"); 22 | } 23 | 24 | @Test 25 | public void itShouldSerializeSFLineStringWithAltitude() throws Exception { 26 | List points = new ArrayList<>(); 27 | points.add(new mil.nga.sf.Point(100d, 10d, 15d)); 28 | points.add(new mil.nga.sf.Point(101d, 1d, 11d)); 29 | mil.nga.sf.LineString lineString = new mil.nga.sf.LineString(points); 30 | TestUtils.compareAsNodes(lineString, 31 | "{\"type\":\"LineString\",\"coordinates\":[[100.0,10.0,15.0],[101.0,1.0,11.0]]}"); 32 | } 33 | 34 | @Test 35 | public void itShouldDeserializeLineString() throws Exception { 36 | GeoJsonObject value = TestUtils.getMapper().readValue( 37 | "{\"type\":\"LineString\",\"coordinates\":[[100.0, 0.0],[101.0, 1.0]]}", 38 | GeoJsonObject.class); 39 | assertNotNull(value); 40 | assertTrue(value instanceof LineString); 41 | LineString lineString = (LineString) value; 42 | List positions = lineString.getCoordinates(); 43 | assertEquals(2, positions.size()); 44 | TestUtils.assertPosition(100d, 0d, null, null, positions.get(0)); 45 | TestUtils.assertPosition(101d, 1.0d, null, null, positions.get(1)); 46 | } 47 | 48 | @Test 49 | public void itShouldDeserializeLineStringWithAltitude() throws Exception { 50 | GeoJsonObject value = TestUtils.getMapper().readValue( 51 | "{\"type\":\"LineString\",\"coordinates\":[[100.0, 10.0, -20.0],[101.0, 1.0, -10.0]]}", 52 | GeoJsonObject.class); 53 | assertNotNull(value); 54 | assertTrue(value instanceof LineString); 55 | LineString lineString = (LineString) value; 56 | List positions = lineString.getCoordinates(); 57 | assertEquals(2, positions.size()); 58 | TestUtils.assertPosition(100d, 10d, -20d, null, positions.get(0)); 59 | TestUtils.assertPosition(101d, 1d, -10d, null, positions.get(1)); 60 | } 61 | 62 | @Test 63 | public void toGeometry() { 64 | TestUtils.toGeometry(getTestGeometry()); 65 | } 66 | 67 | @Test 68 | public void toMap() { 69 | TestUtils.toMap(getTestGeometry()); 70 | } 71 | 72 | @Test 73 | public void toStringValue() { 74 | TestUtils.toStringValue(getTestGeometry()); 75 | } 76 | 77 | private mil.nga.sf.Geometry getTestGeometry() { 78 | 79 | List points = new ArrayList<>(); 80 | points.add(new mil.nga.sf.Point(100d, 10d)); 81 | points.add(new mil.nga.sf.Point(101d, 1d)); 82 | mil.nga.sf.LineString lineString = new mil.nga.sf.LineString(points); 83 | 84 | return lineString; 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /src/test/java/mil/nga/sf/geojson/MultiPointTest.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.geojson; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertNotNull; 5 | import static org.junit.Assert.assertTrue; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | import org.junit.Test; 11 | 12 | public class MultiPointTest { 13 | 14 | private static String MULTIPOINT = "{\"type\":\"MultiPoint\",\"coordinates\":[[100.0,10.0],[101.0,1.0]]}"; 15 | private static String MULTIPOINT_WITH_ALT = "{\"type\":\"MultiPoint\",\"coordinates\":[[100.0,10.0,-20.0],[101.0,1.0,-10.0]]}"; 16 | 17 | @Test 18 | public void itShouldSerializeSFMultiPoint() throws Exception { 19 | List points = new ArrayList<>(); 20 | points.add(new mil.nga.sf.Point(100d, 10d)); 21 | points.add(new mil.nga.sf.Point(101d, 1d)); 22 | mil.nga.sf.MultiPoint multiPoint = new mil.nga.sf.MultiPoint(points); 23 | TestUtils.compareAsNodes(multiPoint, MULTIPOINT); 24 | } 25 | 26 | @Test 27 | public void itShouldSerializeSFMultiPointWithAltitude() throws Exception { 28 | List positions = new ArrayList<>(); 29 | positions.add(new mil.nga.sf.Point(100d, 10d, -20d)); 30 | positions.add(new mil.nga.sf.Point(101d, 1d, -10d)); 31 | mil.nga.sf.MultiPoint multiPoint = new mil.nga.sf.MultiPoint(positions); 32 | TestUtils.compareAsNodes(multiPoint, MULTIPOINT_WITH_ALT); 33 | } 34 | 35 | @Test 36 | public void itShouldDeserializeMultiPoint() throws Exception { 37 | GeoJsonObject value = TestUtils.getMapper().readValue(MULTIPOINT, 38 | GeoJsonObject.class); 39 | assertNotNull(value); 40 | assertTrue(value instanceof MultiPoint); 41 | MultiPoint multiPoint = (MultiPoint) value; 42 | List positions = multiPoint.getCoordinates(); 43 | assertEquals(2, positions.size()); 44 | TestUtils.assertPosition(100d, 10d, null, null, positions.get(0)); 45 | TestUtils.assertPosition(101d, 1.0d, null, null, positions.get(1)); 46 | } 47 | 48 | @Test 49 | public void itShouldDeserializeMultiPointWithAltitude() throws Exception { 50 | GeoJsonObject value = TestUtils.getMapper() 51 | .readValue(MULTIPOINT_WITH_ALT, GeoJsonObject.class); 52 | assertNotNull(value); 53 | assertTrue(value instanceof MultiPoint); 54 | MultiPoint multiPoint = (MultiPoint) value; 55 | List positions = multiPoint.getCoordinates(); 56 | assertEquals(2, positions.size()); 57 | TestUtils.assertPosition(100d, 10d, -20d, null, positions.get(0)); 58 | TestUtils.assertPosition(101d, 1d, -10d, null, positions.get(1)); 59 | } 60 | 61 | @Test 62 | public void toGeometry() { 63 | TestUtils.toGeometry(getTestGeometry()); 64 | } 65 | 66 | @Test 67 | public void toMap() { 68 | TestUtils.toMap(getTestGeometry()); 69 | } 70 | 71 | @Test 72 | public void toStringValue() { 73 | TestUtils.toStringValue(getTestGeometry()); 74 | } 75 | 76 | private mil.nga.sf.Geometry getTestGeometry() { 77 | 78 | List points = new ArrayList<>(); 79 | points.add(new mil.nga.sf.Point(100d, 10d)); 80 | points.add(new mil.nga.sf.Point(101d, 1d)); 81 | mil.nga.sf.MultiPoint multiPoint = new mil.nga.sf.MultiPoint(points); 82 | 83 | return multiPoint; 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /src/test/java/mil/nga/sf/geojson/PointTest.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.geojson; 2 | 3 | import java.io.IOException; 4 | import java.util.ArrayList; 5 | import java.util.Arrays; 6 | 7 | import org.junit.Test; 8 | 9 | import junit.framework.TestCase; 10 | 11 | public class PointTest { 12 | 13 | @Test 14 | public void itShouldSerializeSFPoint() throws Exception { 15 | mil.nga.sf.Point simplePoint = new mil.nga.sf.Point(100d, 10d); 16 | TestUtils.compareAsNodes(simplePoint, 17 | "{\"type\":\"Point\",\"coordinates\":[100.0,10.0]}"); 18 | } 19 | 20 | @Test 21 | public void itShouldDeserializePoint() throws Exception { 22 | GeoJsonObject value = TestUtils.getMapper().readValue( 23 | "{\"type\":\"Point\",\"coordinates\":[100.0,5.0]}", 24 | GeoJsonObject.class); 25 | TestCase.assertNotNull(value); 26 | TestCase.assertTrue(value instanceof Point); 27 | Point point = (Point) value; 28 | TestUtils.assertPoint(100d, 5d, null, point); 29 | } 30 | 31 | @Test 32 | public void itShouldDeserializePointWithAltitude() throws Exception { 33 | GeoJsonObject value = TestUtils.getMapper().readValue( 34 | "{\"type\":\"Point\",\"coordinates\":[100.0,5.0,123]}", 35 | GeoJsonObject.class); 36 | Point point = (Point) value; 37 | TestUtils.assertPoint(100d, 5d, 123d, point); 38 | } 39 | 40 | @Test 41 | public void itShouldSerializePointWithAltitude() throws Exception { 42 | mil.nga.sf.Point simplePoint = new mil.nga.sf.Point(100d, 10d, 256d); 43 | TestUtils.compareAsNodes(simplePoint, 44 | "{\"type\":\"Point\",\"coordinates\":[100.0,10.0,256.0]}"); 45 | } 46 | 47 | @Test 48 | public void itShouldDeserializePointWithAdditionalAttributes() 49 | throws IOException { 50 | GeoJsonObject value = TestUtils.getMapper().readValue( 51 | "{\"type\":\"Point\",\"coordinates\":[100.0,5.0,123,456,789.2]}", 52 | GeoJsonObject.class); 53 | Point point = (Point) value; 54 | TestUtils.assertPoint(100d, 5d, 123d, 55 | new ArrayList<>(Arrays.asList(456d, 789.2)), point); 56 | } 57 | 58 | @Test 59 | public void itShouldSerializePointWithAdditionalAttributes() 60 | throws IOException { 61 | Position position = new Position(100d, 0d, 256d, 345d, 678d); 62 | Point point = Point.fromCoordinates(position); 63 | TestUtils.compareAsNodes(point, 64 | "{\"type\":\"Point\",\"coordinates\":[100.0,0.0,256.0,345.0,678.0]}"); 65 | } 66 | 67 | @Test 68 | public void toGeometry() { 69 | TestUtils.toGeometry(getTestGeometry()); 70 | } 71 | 72 | @Test 73 | public void toMap() { 74 | TestUtils.toMap(getTestGeometry()); 75 | } 76 | 77 | @Test 78 | public void toStringValue() { 79 | TestUtils.toStringValue(getTestGeometry()); 80 | } 81 | 82 | private mil.nga.sf.Geometry getTestGeometry() { 83 | 84 | mil.nga.sf.Point point = new mil.nga.sf.Point(100d, 10d); 85 | 86 | return point; 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /src/test/java/mil/nga/sf/geojson/ReadmeTest.java: -------------------------------------------------------------------------------- 1 | package mil.nga.sf.geojson; 2 | 3 | import java.io.IOException; 4 | import java.util.Map; 5 | 6 | import org.junit.Test; 7 | 8 | import junit.framework.TestCase; 9 | 10 | /** 11 | * README example tests 12 | * 13 | * @author osbornb 14 | */ 15 | public class ReadmeTest { 16 | 17 | /** 18 | * Geometry 19 | */ 20 | private static final mil.nga.sf.Geometry GEOMETRY = new mil.nga.sf.Point( 21 | 1.0, 1.0); 22 | 23 | /** 24 | * {@link #GEOMETRY} content 25 | */ 26 | private static final String CONTENT = "{\"type\":\"Point\",\"coordinates\":[1.0,1.0]}"; 27 | 28 | /** 29 | * Test read 30 | * 31 | * @throws IOException 32 | * upon error 33 | */ 34 | @Test 35 | public void testRead() throws IOException { 36 | 37 | Geometry geometry = testRead(CONTENT); 38 | 39 | TestCase.assertEquals(GEOMETRY, geometry.getGeometry()); 40 | 41 | } 42 | 43 | /** 44 | * Test read 45 | * 46 | * @param content 47 | * content 48 | * @return geometry 49 | * @throws IOException 50 | * upon error 51 | */ 52 | private Geometry testRead(String content) throws IOException { 53 | 54 | // String content = ... 55 | 56 | Geometry geometry = FeatureConverter.toGeometry(content); 57 | mil.nga.sf.Geometry simpleGeometry = geometry.getGeometry(); 58 | 59 | /* Read as a generic GeoJSON object, Feature, or Feature Collection */ 60 | // GeoJsonObject geoJsonObject = 61 | // FeatureConverter.toGeoJsonObject(content); 62 | // Feature feature = FeatureConverter.toFeature(content); 63 | // FeatureCollection featureCollection = 64 | // FeatureConverter.toFeatureCollection(content); 65 | 66 | return geometry; 67 | } 68 | 69 | /** 70 | * Test write 71 | * 72 | * @throws IOException 73 | * upon error 74 | */ 75 | @Test 76 | public void testWrite() throws IOException { 77 | 78 | String content = testWrite(GEOMETRY); 79 | 80 | TestCase.assertEquals(CONTENT, content); 81 | 82 | } 83 | 84 | /** 85 | * Test write 86 | * 87 | * @param geometry 88 | * geometry 89 | * @return content 90 | * @throws IOException 91 | * upon error 92 | */ 93 | private String testWrite(mil.nga.sf.Geometry geometry) throws IOException { 94 | 95 | // Geometry geometry = ... 96 | 97 | String content = FeatureConverter.toStringValue(geometry); 98 | 99 | Feature feature = FeatureConverter.toFeature(geometry); 100 | String featureContent = FeatureConverter.toStringValue(feature); 101 | 102 | FeatureCollection featureCollection = FeatureConverter 103 | .toFeatureCollection(geometry); 104 | String featureCollectionContent = FeatureConverter 105 | .toStringValue(featureCollection); 106 | 107 | Map contentMap = FeatureConverter.toMap(geometry); 108 | 109 | return content; 110 | } 111 | 112 | } 113 | -------------------------------------------------------------------------------- /src/test/resources/fc-points-altitude.geojson: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "type": "FeatureCollection", 4 | "features": [ 5 | { 6 | "type": "Feature", 7 | "id": "asfd#456", 8 | "geometry": { 9 | "type": "Point", 10 | "coordinates": [ 11 | -5.78, 12 | 4.3, 13 | 121.0 14 | ] 15 | }, 16 | "properties": { 17 | "ID": 456 18 | } 19 | }, 20 | { 21 | "type": "Feature", 22 | "id": "gserg#897", 23 | "geometry": { 24 | "type": "LineString", 25 | "coordinates": [ 26 | [ 27 | -8.6, 28 | 2.86, 29 | 7.7, 30 | 131 31 | ], 32 | [ 33 | -8.6, 34 | 2.86, 35 | 109.6648, 36 | 131 37 | ], 38 | [ 39 | -51.8787, 40 | 4.66, 41 | 129646.8591, 42 | 131 43 | ] 44 | ] 45 | }, 46 | "properties": { 47 | "ID": 897 48 | } 49 | } 50 | ] 51 | } 52 | -------------------------------------------------------------------------------- /src/test/resources/fc-points.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type": "FeatureCollection", 3 | "features": [ 4 | { 5 | "type": "Feature", 6 | "geometry": { 7 | "type": "Point", 8 | "coordinates": [ 9 | -80.87088507656375, 10 | 35.21515162500578 11 | ] 12 | }, 13 | "properties": { 14 | "name": "ABBOTT NEIGHBORHOOD PARK", 15 | "address": "1300 SPRUCE ST" 16 | } 17 | }, 18 | { 19 | "type": "Feature", 20 | "geometry": { 21 | "type": "Point", 22 | "coordinates": [ 23 | -80.83775386582222, 24 | 35.24980190252168 25 | ] 26 | }, 27 | "properties": { 28 | "name": "DOUBLE OAKS CENTER", 29 | "address": "1326 WOODWARD AV" 30 | } 31 | }, 32 | { 33 | "type": "Feature", 34 | "geometry": { 35 | "type": "Point", 36 | "coordinates": [ 37 | -80.83827000459532, 38 | 35.25674709224663 39 | ] 40 | }, 41 | "properties": { 42 | "name": "DOUBLE OAKS NEIGHBORHOOD PARK", 43 | "address": "2605 DOUBLE OAKS RD" 44 | } 45 | }, 46 | { 47 | "type": "Feature", 48 | "geometry": { 49 | "type": "Point", 50 | "coordinates": [ 51 | -80.83697759172735, 52 | 35.25751734669229 53 | ] 54 | }, 55 | "properties": { 56 | "name": "DOUBLE OAKS POOL", 57 | "address": "1200 NEWLAND RD" 58 | } 59 | }, 60 | { 61 | "type": "Feature", 62 | "geometry": { 63 | "type": "Point", 64 | "coordinates": [ 65 | -80.81647652154736, 66 | 35.40148708491418 67 | ] 68 | }, 69 | "properties": { 70 | "name": "DAVID B. WAYMER FLYING REGIONAL PARK", 71 | "address": "15401 HOLBROOKS RD" 72 | } 73 | }, 74 | { 75 | "type": "Feature", 76 | "geometry": { 77 | "type": "Point", 78 | "coordinates": [ 79 | -80.83556459443902, 80 | 35.39917224760999 81 | ] 82 | }, 83 | "properties": { 84 | "name": "DAVID B. WAYMER COMMUNITY PARK", 85 | "address": "302 HOLBROOKS RD" 86 | } 87 | } 88 | ] 89 | } -------------------------------------------------------------------------------- /src/test/resources/gc.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type": "FeatureCollection", 3 | "features": [{ 4 | "type": "Feature", 5 | "properties": {}, 6 | "geometry": { 7 | "type": "GeometryCollection", 8 | "geometries": [{ 9 | "type": "Point", 10 | "coordinates": [ 11 | 61.34765625, 12 | 48.63290858589535 13 | ] 14 | }, { 15 | "type": "Polygon", 16 | "coordinates": [ 17 | [ 18 | [ 19 | 59.94140624999999, 20 | 50.65294336725709 21 | ], 22 | [ 23 | 54.931640625, 24 | 50.90303283111257 25 | ], 26 | [ 27 | 51.943359375, 28 | 51.04139389812637 29 | ], 30 | [ 31 | 50.9765625, 32 | 48.19538740833338 33 | ], 34 | [ 35 | 52.55859375, 36 | 46.46813299215554 37 | ], 38 | [ 39 | 52.998046875, 40 | 43.8028187190472 41 | ], 42 | [ 43 | 54.4921875, 44 | 42.391008609205045 45 | ], 46 | [ 47 | 57.041015625, 48 | 43.29320031385282 49 | ], 50 | [ 51 | 59.8974609375, 52 | 45.398449976304086 53 | ], 54 | [ 55 | 62.5341796875, 56 | 44.08758502824516 57 | ], 58 | [ 59 | 65.6982421875, 60 | 45.73685954736049 61 | ], 62 | [ 63 | 68.37890625, 64 | 48.3416461723746 65 | ], 66 | [ 67 | 65.8740234375, 68 | 49.18170338770663 69 | ], 70 | [ 71 | 63.720703125, 72 | 49.97948776108648 73 | ], 74 | [ 75 | 63.80859374999999, 76 | 52.348763181988076 77 | ], 78 | [ 79 | 61.4794921875, 80 | 52.32191088594773 81 | ], 82 | [ 83 | 59.9853515625, 84 | 51.86292391360244 85 | ], 86 | [ 87 | 61.9189453125, 88 | 51.09662294502995 89 | ], 90 | [ 91 | 60.5126953125, 92 | 50.51342652633956 93 | ], 94 | [ 95 | 59.94140624999999, 96 | 50.65294336725709 97 | ] 98 | ] 99 | ] 100 | }] 101 | } 102 | }] 103 | } 104 | --------------------------------------------------------------------------------