Giter Site home page Giter Site logo

ngageoint / simple-features-geojson-java Goto Github PK

View Code? Open in Web Editor NEW
33.0 8.0 12.0 1 MB

Simple Features GeoJSON Java Library

Home Page: https://ngageoint.github.io/simple-features-geojson-java/

License: MIT License

Java 100.00%
simple-features geojson geojson-features nga ogc features features-geojson

simple-features-geojson-java's Introduction

Simple Features GeoJSON Java

Simple Features GeoJSON Lib

The Simple Features Libraries were developed at the National Geospatial-Intelligence Agency (NGA) in collaboration with 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.

Pull Requests

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.

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.

About

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

Usage

View the latest Javadoc

Read

//String content = ...    

Geometry geometry = FeatureConverter.toGeometry(content);
mil.nga.sf.Geometry simpleGeometry = geometry.getGeometry();

/* Read as a generic GeoJSON object, Feature, or Feature Collection */
//GeoJsonObject geoJsonObject = FeatureConverter.toGeoJsonObject(content);
//Feature feature = FeatureConverter.toFeature(content);
//FeatureCollection featureCollection = FeatureConverter.toFeatureCollection(content);

Write

//Geometry geometry = ...

String content = FeatureConverter.toStringValue(geometry);

Feature feature = FeatureConverter.toFeature(geometry);
String featureContent = FeatureConverter.toStringValue(feature);

FeatureCollection featureCollection = FeatureConverter.toFeatureCollection(geometry);
String featureCollectionContent = FeatureConverter.toStringValue(featureCollection);

Map<String, Object> contentMap = FeatureConverter.toMap(geometry);

Installation

Pull from the Maven Central Repository (JAR, POM, Source, Javadoc)

<dependency>
    <groupId>mil.nga.sf</groupId>
    <artifactId>sf-geojson</artifactId>
    <version>3.3.3</version>
</dependency>

Build

Build & Test

Build this repository using Eclipse and/or Maven:

mvn clean install

Remote Dependencies

simple-features-geojson-java's People

Contributors

bosborn avatar jyutzler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

simple-features-geojson-java's Issues

mil.nga.sf.geojson.Position.additionalElements: lost additional when FeatureConverter.toStringValue()

Please fill out as much known and relevant information as possible.

Version Information:

  • SF GeoJSON Java Version: mil.nga.sf:sf-geojson:2.0.4
  • SF GeoJSON Java Source: Central Repository
  • IDE Name & Version: Android Studio
  • Maven Version: Gradle
  • Java Version: 8
  • Platform & OS: Android 10
  • Other Relevant Libraries: -

Expected Results:

  • What did you expect to happen?

two additional element after FeatureConverter.toStringValue().

Observed Results:

  • What happened instead?
    only one additional element.

  • How often does this occur?

        List<Position> pointList = new ArrayList<>();
        for (DbTrackPoint tp : t.getPoints()) {
          pointList.add(
              new Position(
                  tp.getLon(), tp.getLat(), tp.getAlt(),
                  1d,
                  2d
              )
          );
        }
        LineString line = new LineString();
        line.setCoordinates(pointList);

        Map<String, Object> propertyMap = new LinkedHashMap<>();
        propertyMap.put("source", SOURCE);

        Feature lineFeature = new Feature(line);
        lineFeature.setProperties(propertyMap);
        featureCollection.addFeature(lineFeature);

      FileUtils.writeStringToFile(
          file,
          FeatureConverter.toStringValue(featureCollection),
          "UTF-8"
      );

But 2 lost, only 1 keep:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "LineString",
        "coordinates": [
          [
            114.41760627,
            30.47035912,
            14.82720947265625,
            1.0
          ],
          [
            114.41777497,
            30.47037775,
            17.23809814453125,
            1.0
          ]
...

Additional Information:

Can i add more than one additionalElements? Why only one?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.