Skip to content

Conversation

gdey
Copy link
Member

@gdey gdey commented Jan 20, 2021

The current way of using the geojson package requires one to wrap a geometry several times.

This PR introduces three new methods to simplify using the package.

  1. Marshal -- which will take any geom.Geometry, or slice of geom.Geometries, or a geojson.Feature, or a geojson.FeatureCollection and return a geojson encoded version of it, or an error.
  2. MarshalIndent is the same as Marshal, returning a pretty version of the output instead
  3. Unmarshal which will take an encoded geojson byte slice, and return either a geojson.Feature, or a geojson.FeatureCollection.
  • In addition to the above a few documentation updates, and general fixes.

@gbroccolo could you give this a review as well. Thank you.

@gdey gdey requested a review from ARolek January 20, 2021 19:27
@gdey gdey self-assigned this Jan 20, 2021
@coveralls
Copy link

coveralls commented Jan 20, 2021

Pull Request Test Coverage Report for Build 514

  • 53 of 121 (43.8%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.1%) to 56.076%

Changes Missing Coverage Covered Lines Changed/Added Lines %
encoding/geojson/geojson.go 53 121 43.8%
Totals Coverage Status
Change from base Build 512: -0.1%
Covered Lines: 6691
Relevant Lines: 11932

💛 - Coveralls

Copy link
Member

@ARolek ARolek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

// mapping between JSON and geom Geometry values are described in
// the documentation for the Marshal and Unmarshal functions.
//
// At current this pacakge only supports 2D Geometries unless stated
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

package is misspelled as 'pacakge'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, change 'stated otherwise' to 'otherwise stated'

@gbroccolo
Copy link
Collaborator

LGTM. No need to include extended geometries since they are not include in the GeoJSON standard.

gdey added 4 commits March 15, 2021 09:53
* Added additional information about package to main README.md file.
* Documented the errors and rearranged code for error.go to make it
    easier to read the code.
* Added pacakge documentation with references to appropriate RFC.
* Improved documentation for methods.
* Added a general Marshal function to the geojson package to make
using the package easier. Currently you have to write a geom Geometry
object with a geojson Geometry object and then a Feature object. This
is ugly.

The new Marshal function will take care of the wrapping as needed.

* Added a general MarshalIndent function that behaves like Marshal, but
returns and indented version of the geojson.
* Add an Unmarshal function to the top level of geojson,
to allow simpler unmarshalling of geojson Features and
FeatureCollections.
@gdey gdey merged commit 0e06498 into master Mar 15, 2021
@gdey gdey deleted the improve_docs branch March 15, 2021 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants