No commit activity in last 3 years
No release in over 3 years
Converts GeoSparql to GeoJSON
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.14
~> 10.0
~> 3.0
~> 0.12

Runtime

 Project Readme

GeosparqlToGeojson

GeosparqlToGeojson is a gem created by the Parliamentary Digital Service to take GeoSparql data and convert it into GeoJSON data.

Gem Build Status Test Coverage License

NOTE: This gem is in active development and is likely to change at short notice. It is not recommended that you use this in any production environment.

Contents

  • Requirements
  • Installation
  • Usage
  • Getting Started with Development
    • Running the tests
  • Contributing
  • License

Requirements

GeosparqlToGeojson requires the following:

Installation

gem 'geosparql_to_geojson'

Usage

This gem's main function is taking a GeoSparql string and converting it into GeoJSON.

Calling GeosparqlToGeojson#convert_to_geojson and passing in valid GeoSparql string will convert the GeoSparql to GeoJSON and return a GeosparqlToGeojson::GeoJson object.

Properties can optionally be passed in as well as whether the data should be reversed during the convertion.

geosparql = 'POINT(0.1, 51.5)'
properties = {name: 'London'}

point = GeosparqlToGeojson.convert_to_geojson(geosparql_values: geosparql, geosparql_properties: properties, reverse: true)
#=> GeosparqlToGeojson::GeoJson

Calling point.geojson will return a GeoJSON string. For example:

{"type": "FeatureCollection",
  "features": [
    {
       "type": "Feature",
       "geometry": {
         "type": "Point",
         "coordinates": [
          51.5,
          0.1
        ]
      },
      "properties": {"name": "London"}
    }
  ]
}

Calling point.validate will return a GeosparqlToGeojson::Validator object which can be used to validate the generated GeoJSON.

validated_geojson = GeosparqlToGeojson::Validator.new(point)

validated_geojson.valid?
#=> true

validated_geojson.errors
#=> []

Getting Started with Development

To clone the repository and set up the dependencies, run the following:

git clone https://github.com/ukparliament/geosparql_to_geojson.git
cd geosparql_to_geojson
bundle install

Running the tests

We use RSpec as our testing framework and tests can be run using:

bundle exec rspec

Contributing

If you wish to submit a bug fix or feature, you can create a pull request and it will be merged pending a code review.

  1. Fork the repository
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Ensure your changes are tested using Rspec
  6. Create a new Pull Request

License

GeosparqlToGeojson is licensed under the Open Parliament Licence.