Git Product home page Git Product logo

geoserver-publish's Introduction

Geoserver::Publish

Build Status Coverage Status

Simple client for publishing Shapefiles and GeoTIFFs to Geoserver.

Installation

Add this line to your application's Gemfile:

gem 'geoserver-publish'

And then execute:

$ bundle

Or install it yourself as:

$ gem install geoserver-publish

Usage

GeoTIFF

Geoserver::Publish.geotiff(workspace_name: "public", file_path: "file:///path/on/geoserver/raster.tif", id: "1234", title: "GeoTiff Title")

Shapefile

Because of a limitation in GeoServer, the layer id must be the same name as the shapefile without the extenstion. For example, if the file name is 1234.shp, the id must be 1234.

Geoserver::Publish.shapefile(workspace_name: "public", file_path: "file:///path/on/geoserver/1234.shp", id: "1234", title: "Shapefile Title")

Deleting

Geoserver::Publish.delete_geotiff(workspace_name: "public", id: "1234")
Geoserver::Publish.delete_shapefile(workspace_name: "public", id: "1234")

Styles

For users wanting to publish styles, this can be done using the GeoServer styles API.

Geoserver::Publish::Style.new.create(style_name: "raster_layer", filename: "raster_layer.sld")
sld = File.read("./spec/fixtures/files/payload/raster_layer.sld")
Geoserver::Publish::Style.new.update(style_name: "raster_layer", filename: "raster_layer.sld", payload: sld)

GeoWebCache

The GeoWebCache REST API can also be used. Note: there is usually a different url that is used.

c = Geoserver::Publish::Connection.new({"url" => "http://localhost:8080/geoserver/gwc/rest", "user"=>"admin",
"password"=>"geoserver"})
Geoserver::Publish::Geowebcache.new(c).masstruncate(layer_name: 'nurc:Pk50095')

Configuration

Default

To use the default GeoServer connection parameters, no further configuration is needed. These are useful for testing and development against a local GeoServer instance.

Environment Variables

GeoServer Connection parameters can be set using environment variables.

  • GEOSERVER_URL
  • GEOSERVER_USER
  • GEOSERVER_PASSWORD

Connection Object

A connection object can be instantiated with a parameter hash and passed into publishing methods.

new_conn = Geoserver::Publish::Connection.new({"url"=> "http://mygeoserver.com:8181/geoserver/rest", "user" => "admin_user", "password" => "supersecret"})
Geoserver::Publish.geotiff(connection: new_conn, workspace_name: "public", file_path: "file:///path/on/geoserver/raster.tif", id: "1234", title: "GeoTiff Title")

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/samvera-labs/geoserver-publish.

geoserver-publish's People

Contributors

eliotjordan avatar jrgriffiniii avatar mcritchlow avatar mejackreed avatar vivianchu avatar

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.