geoserver is a Go library for manipulating a GeoServer instance via the GeoServer REST API.

Overview

Go Report Card GitHub license GitHub issues Coverage Status Build Status Documentation GitHub forks GitHub stars Twitter

Geoserver

geoserver Is a Go Package For Manipulating a GeoServer Instance via the GeoServer REST API.


How to install:

  • go get -v gopkg.in/hishamkaram/geoserver.v1
    • now you can import the package from gopkg.in/hishamkaram/geoserver.v1, example:
      import (
        ...
        "gopkg.in/hishamkaram/geoserver.v1"
        ...
      )
      

usage:

  • Create new Catalog (which contains all available operations):
    • gsCatalog := geoserver.GetCatalog("http://localhost:8080/geoserver13/", "admin", "geoserver")
  • Use catalog Methods to Perform a Geoserver REST Operation:
    • Create New workspace:
      created, err := gsCatalog.CreateWorkspace("golang")
      if err != nil {
        fmt.Printf("\nError:%s\n", err)
      }
      fmt.Println(strconv.FormatBool(created))
      
      output if created:
      INFO[31-03-2018 16:26:35] url:http://localhost:8080/geoserver13/rest/workspaces	response Status=201  
      true
      
      output if error:
      INFO[31-03-2018 16:26:37] url:http://localhost:8080/geoserver13/rest/workspaces	response Status=401  
      WARN[31-03-2018 16:26:37] <!doctype html><html lang="en"><head><title>HTTP Status 401 – Unauthorized</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 401 – Unauthorized</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> Workspace &#39;golang&#39; already exists</p><p><b>Description</b> The request has not been applied because it lacks valid authentication credentials for the target resource.</p><hr class="line" /><h3>Apache Tomcat/9.0.6</h3></body></html> 
      
      Error:Unauthorized
      false
      
  • Get Layers through GetLayers take workspace as paramter if empty workspace will be ignored and geoserver will return all public layers
    layers, err := gsCatalog.GetLayers("")
    if err != nil {
      fmt.Printf("\nError:%s\n", err)
    }
    for _, lyr := range layers {
      fmt.Printf("\nName:%s  href:%s\n", lyr.Name, lyr.Href)
    }
    
    output:
    INFO[31-03-2018 19:04:44] url:http://localhost:8080/geoserver13/rest/layers	response Status=200  
    
    Name:tiger:giant_polygon  href:http://localhost:8080/geoserver13/rest/layers/tiger%3Agiant_polygon.json
    
    Name:tiger:poi  href:http://localhost:8080/geoserver13/rest/layers/tiger%3Apoi.json
    
    Name:tiger:poly_landmarks  href:http://localhost:8080/geoserver13/rest/layers/tiger%3Apoly_landmarks.json
    
    Name:tiger:tiger_roads  href:http://localhost:8080/geoserver13/rest/layers/tiger%3Atiger_roads.json
    
    Name:nurc:Arc_Sample  href:http://localhost:8080/geoserver13/rest/layers/nurc%3AArc_Sample.json
    
    Name:nurc:Img_Sample  href:http://localhost:8080/geoserver13/rest/layers/nurc%3AImg_Sample.json
    
    Name:nurc:Pk50095  href:http://localhost:8080/geoserver13/rest/layers/nurc%3APk50095.json
    
    Name:nurc:mosaic  href:http://localhost:8080/geoserver13/rest/layers/nurc%3Amosaic.json
    ......
    
  • Get Specific Layer from Geoserver:
    layer, err := gsCatalog.GetLayer("nurc", "Arc_Sample")
    if err != nil {
      fmt.Printf("\nError:%s\n", err)
    } else {
      fmt.Printf("%+v\n", layer)
    }
    
    output:
    INFO[31-03-2018 20:12:07] url:http://localhost:8080/geoserver13/rest/workspaces/nurc/layers/Arc_Sample	response Status=200  
    {Name:Arc_Sample Path:/ Type:RASTER DefaultStyle:{Class: Name:rain Href:http://localhost:8080/geoserver13/rest/styles/rain.json} Styles:{Class:linked-hash-set Style:[{Class: Name:raster Href:http://localhost:8080/geoserver13/rest/styles/raster.json}]} Resource:{Class:coverage Name:nurc:Arc_Sample Href:http://localhost:8080/geoserver13/rest/workspaces/nurc/coveragestores/arcGridSample/coverages/Arc_Sample.json} Queryable:false Opaque:false Attribution:{Title: Href: LogoURL: LogoType: LogoWidth:0 LogoHeight:0}}
    
  • You can find more examples by check testing files
  • You can find all supported operations on Godocs

TESTING

Go Version Geoserver Version Tested
1 1.11.x 2.13.x ✔️
2 1.11.x 2.14.x ✔️
3 1.12.x 2.13.x ✔️
4 1.12.x 2.14.x ✔️
5 1.13.x 2.13.x ✔️
6 1.13.x 2.14.x ✔️

Documentation

Comments
  • A lot of missing methods was implemented including commands to control user, group, roles, acl etc

    A lot of missing methods was implemented including commands to control user, group, roles, acl etc

    Hello, this is PR where a lot of missing methods was implemented :

    • Methods to control users, groups, roles, and acl commands (create, delete)
    • Method to create new FeatureType (for datastorages like postgress etc)
    • Method to create Postgis JNDI datastorage connection
    • DatastoreConnection struct was expanded with Options field allowing set additional datastorage options like "max connections", "Expose primary keys" etc
    • Some broken tests were fixed or rewritten
    • Testing environment configuration was moved to .yml file
    opened by mandalorian-one 3
  • I have some problem,when i want to get layerGroups data by your api

    I have some problem,when i want to get layerGroups data by your api

    i can't find get layerGroup's method, in your code. but i have fix it now by learning your code, thank you very much

    `

        type Group struct {
            Type string `json:"@type,omitempty" xml:"type"`
            Name string `json:"name,omitempty" xml:"name"`
            Href string `json:"href,omitempty" xml:"href"`
        }
        type LayerGroup struct {
            Name      string `json:"name" xml:"name"`
            Mode      string `json:"mode" xml:"mode"`
            Title     string `json:"title" xml:"title"`
            Workspace struct {
    	        Name string `json:"name" xml:"name"`
            } `json:"workspace" xml:"workspace"`
            Publishables struct {
    	        Published []*Group `json:"published" xml:"published"`
            } `json:"publishables" xml:"publishables"`
            Styles struct {
    	        Style []*Group `json:"style" xml:"style"`
            } `json:"styles" xml:"styles"`
            Bounds struct {
    	        MinX float64 `json:"minx" xml:"minx"`
    	        MinY float64 `json:"miny" xml:"miny"`
    	        MaxX float64 `json:"maxx" xml:"maxx"`
    	        MaxY float64 `json:"maxy" xml:"maxy"`
    	        Crs  string  `json:"crs" xml:"crs"`
            } `json:"bounds" xml:"bounds"`
        }
    
        type LayerGroups struct {
            LayerGroup LayerGroup `json:"layerGroup" xml:"layerGroup"`
        }
        target := utils.Catalog.ParseURL("rest", "workspaces", workspace.Name, "layergroups", "xxxx")
    request := geoserver.HTTPRequest{
    	Method: "GET",
    	Accept: "application/json",
    	URL:    target,
    	Query:  nil,
    }
    response, code := utils.Catalog.DoRequest(request)
    if code != http.StatusOK {
    	utils.Logger.Error("get layer groups error", zap.Int("error code", code))
    	c.JSON(http.StatusInternalServerError, utils.BaseResponse(http.StatusInternalServerError, "internal server error", c.Request.RequestURI, nil))
    	return
    }
    var groups defs.LayerGroups
    utils.Catalog.DeSerializeJSON(response, &groups)
    server := &defs.Server{
    	BaseServiceUrl: utils.Catalog.ParseURL(workspace.Name, "wms?"),
    	Layers:         fmt.Sprintf("%s:%s", groups.LayerGroup.Workspace.Name, groups.LayerGroup.Name),
    	TilematrixSet:  groups.LayerGroup.Bounds.Crs,
    }
    

    `

    New Feature in-progress 
    opened by 0x2d3c 3
  • Allowed schema to be changed in DatastoreConnection

    Allowed schema to be changed in DatastoreConnection

    I have added a DBSchema field to the DatastoreConnection so created Datastores can use a specific schema.

    I've added some conditional logic in CreateDatastore such that if DBSchema is not set, it will default to public.

    I haven't implemented retrieving this information in GET requests etc. so may need some more consideration.

    opened by deltabrot 2
  • Cannot Customize http client

    Cannot Customize http client

    If I try to connect to a geoserver with a self-signed cert geoserver fails. I suggest a way to customize the http client that the Geoserver struct is using. Currently it is unexported and I dont see a way to use a custom client if needed.

    bug 
    opened by alienatorZ 2
  • i found you forgot a method about GetCoverageStore,right?

    i found you forgot a method about GetCoverageStore,right?

    func (g *GeoServer) GetCoverageStore(workspaceName, gridName string) (coverageStore *CoverageStore, err error) {
    	targetURL := g.ParseURL("rest", "workspaces", workspaceName, "coveragestores", gridName)
    	httpRequest := HTTPRequest{
    		Method: getMethod,
    		Accept: jsonType,
    		URL:    targetURL,
    		Query:  nil,
    	}
    	response, responseCode := g.DoRequest(httpRequest)
    	if responseCode != statusOk {
    		g.logger.Error(string(response))
    		coverageStore = nil
    		err = g.GetError(responseCode, response)
    		return
    	}
    	var coverageStoreResponse struct {
    		CoverageStore *CoverageStore
    	}
    	g.DeSerializeJSON(response, &coverageStoreResponse)
    	coverageStore = coverageStoreResponse.CoverageStore
    	return
    }
    
    enhancement in-progress 
    opened by 0x2d3c 2
  • Set of methods to work with raster layers (coverages)

    Set of methods to work with raster layers (coverages)

    There are a set of methods to work with raster layers, including:

    • get a list of raster layers (coverages): GetCoverages
    • get a list of raster layers in the coverageStore, including unpublished layers: GetStoreCoverages
    • get raster layer structure (coverage): GetCoverage
    • delete and update raster layer: DeleteCoverage, UpdateCoverage
    • publishing the raster layer from the coverageStore: PublishCoverage

    PublishGeoTiffLayer is refactored and moved from layers.go to coverages.go because this is a more suitable place for raster layers methods

    Tests for all these methods were also implemented

    opened by mandalorian-one 1
  • Implemented coveragestore coverages endpoint to allow the publishing of GeoTIFF layers

    Implemented coveragestore coverages endpoint to allow the publishing of GeoTIFF layers

    In fairness, this was a pretty rushed effort in an attempt to get some desired functionality out of your repo. However I've tried to stick to your conventions.

    opened by deltabrot 1
  • Updated error logging

    Updated error logging

    Background

    This PR contains small fixes for error logging.

    What have changed

    • Removed debug logging using fmt.Printf
    • Added status code logging into error message
    opened by FedorZaytsev 1
  • AMP changes

    AMP changes

    I'm afraid this PR is a bit messy. At this point I am mostly hoping to get an indication of interest for the changes in here. If there is interest we can work on cleaning things up and creating a a set of smaller PRs for individual changes.

    This PR is a collection of changes that have been made by the AMP team in Woven Planet to help us configure geoserver clusters. The changes include:

    • support for additional endpoints
    • a couple of bugfixes
    • some code cleanup (gitignore, use stdlib http status, use of go modules
    • simpify the docker container
    opened by wichert 4
Releases(v1)
Owner
Hisham waleed karam
A highly focused software developer. Organised, methodical and a keen eye for detail results in solid coding and trustworthy software programmes.
Hisham waleed karam
Go bindings for OpenGL (generated via glow)

gl This repository holds Go bindings to various OpenGL versions. They are auto-generated using Glow. Features: Go functions that mirror the C specific

OpenGL with Golang 928 Sep 23, 2022
Go bindings for OpenCV / 2.x API in gocv / 1.x API in opencv

Go OpenCV binding A Golang binding for OpenCV. OpenCV 1.x C API bindings through CGO, and OpenCV 2+ C++ API (GoCV) through SWIG. Disclaimer This is a

go-opencv 1.3k Sep 27, 2022
Canvas is a Go drawing library based on OpenGL or using software rendering that is very similar to the HTML5 canvas API

Go canvas Canvas is a pure Go library that provides drawing functionality as similar as possible to the HTML5 canvas API. It has nothing to do with HT

Thomas Friedel 433 Sep 21, 2022
Cgo bindings to PulseAudio's Simple API, for easily playing or capturing raw audio.

pulse-simple Cgo bindings to PulseAudio's Simple API, for easily playing or capturing raw audio. The full Simple API is supported, including channel m

Tommy 22 Sep 10, 2022
Vulkan API bindings for Go programming language

Golang Bindings for Vulkan API Package vulkan provides Go bindings for Vulkan — a low-overhead, cross-platform 3D graphics and compute API. Updated Oc

null 647 Sep 22, 2022
Go binding to ImageMagick's MagickWand C API

Go Imagick Go Imagick is a Go bind to ImageMagick's MagickWand C API. We support two compatibility branches: master (tag v2.x.x): 6.9.1-7 <= ImageMagi

Go Graphics community 1.5k Sep 26, 2022
Go Graphics - 2D rendering in Go with a simple API.

Go Graphics gg is a library for rendering 2D graphics in pure Go. Installation go get -u github.com/fogleman/gg Alternatively, you may use gopkg.in t

Michael Fogleman 3.6k Oct 2, 2022
A simple API written in Go that creates badges in SVG format, based on the requested route.

A simple API written in Go that creates badges in SVG format, based on the requested route. Those graphics can be used to style README.md files, or to add tags to webpages.

Toby 3 Jul 2, 2021
Use Windows API to capture a image from a Webcam in GoLANG

Windows-API-Capture-Webcam Use Windows API to capture a image from a Webcam in GoLANG Other Go is a amazing and powerful programming language. If you

SaturnsVoid 10 Aug 13, 2022
API-first image file text search 🔍

API-first image file text search ??

John Forstmeier 2 Dec 11, 2021
HTML Canvas 2D Context API for mobile, desktop and web

canvas HTML Canvas 2D Context API for mobile, desktop and web Context2D API https://www.w3.org/TR/2dcontext/ native code implement https://github.com/

GoPlus 2 Apr 22, 2022
An API which allows you to upload an image and responds with the same image, stripped of EXIF data

strip-metadata This is an API which allows you to upload an image and responds with the same image, stripped of EXIF data. How to run You need to have

Cristina Simionescu 0 Nov 25, 2021
API for generate image to ASCII Art

ASCII API Generate ASCII art from image. You can try this API here: ascii.projec

Sh4yn 5 Jul 1, 2022
General purpose library for reading, writing and working with OpenStreetMap data

osm This package is a general purpose library for reading, writing and working with OpenStreetMap data in Go (golang). It has the ability to read OSM

Paul Mach 235 Sep 22, 2022
S2 geometry library in Go

Overview S2 is a library for spherical geometry that aims to have the same robustness, flexibility, and performance as the best planar geometry librar

Go 1.4k Sep 29, 2022
Go package for fast high-level image processing powered by libvips C library

bimg Small Go package for fast high-level image processing using libvips via C bindings, providing a simple programmatic API. bimg was designed to be

Tom 2.1k Oct 1, 2022
Image processing library and rendering toolkit for Go.

blend Image processing library and rendering toolkit for Go. (WIP) Installation: This library is compatible with Go1. go get github.com/phrozen/blend

Guillermo Estrada 60 Aug 14, 2022
Go bindings to OpenGL Utility Library

GLU This package offers minimal bindings for GLU functions. Usage go get github.com/go-gl-legacy/glu License Copyright 2012 The go-gl Authors. All ri

go-gl legacy 21 Aug 18, 2018
Go binding for the cairo graphics library

go-cairo Go binding for the cairo graphics library Based on Dethe Elza's version https://bitbucket.org/dethe/gocairo but significantly extended and up

Erik Unger 124 Sep 26, 2022