Go bindings for the Cartographic Projections Library PROJ.4

Related tags

GIS go-proj-4
Overview

The Go package proj provides a limited interface to the Cartographic Projections Library PROJ.

For PROJ version 5 and beyond, see also: https://github.com/pebbe/proj

Keywords: cartography, cartographic projection

Install

For PROJ.4 and PROJ versions 5 and 6:

go get github.com/pebbe/go-proj-4/proj

For PROJ version 5 and beyond:

go get github.com/pebbe/go-proj-4/proj/v5

Docs

Comments
  • create alloc free version of transform

    create alloc free version of transform

    func transform(srcpj, dstpj *Proj, x, y, z []float64) ([]float64, []float64, []float64, error)

    always allocates the result []float64. this can be improved with

    func transform(srcpj, dstpj *Proj, x, y, z []float64, u, v, w []float64) (error)

    opened by jackielii 4
  • Concurrent access causes panic

    Concurrent access causes panic

    When running Transform in goroutines, it will intermittently panic:

    e = C.transform(srcpj.pj, dstpj.pj, C.long(ln), &x1[0], &y1[0], nil)
    

    Here's the panic:

    fatal error: unexpected signal during runtime execution
    
    goroutine 12 [syscall, locked to thread]:
    runtime.cgocall_errno(0x40047c0, 0xc2080e9788, 0xc200000000)
        /usr/local/go/src/runtime/cgocall.go:130 +0xf5 fp=0xc2080e9768 sp=0xc2080e9740
    github.com/pebbe/go-proj-4/proj._Cfunc_transform(0x9300100, 0x9300540, 0x1, 0xc2081c0650, 0xc2081c0658, 0x0, 0x0)
        github.com/pebbe/go-proj-4/proj/_obj/_cgo_gotypes.go:79 +0x44 fp=0xc2080e9788 sp=0xc2080e9768
    github.com/pebbe/go-proj-4/proj.transform(0xc20802c970, 0xc20802c990, 0xc2080e99a8, 0x1, 0x1, 0xc2080e99a0, 0x1, 0x1, 0x0, 0x0, ...)
        /Users/Shared/Development/git.urban4m.com/projects/AP/app-tiler/src/github.com/pebbe/go-proj-4/proj/proj.go:114 +0xac1 fp=0xc2080e98e8 sp=0xc2080e9788
    github.com/pebbe/go-proj-4/proj.Transform2(0xc20802c970, 0xc20802c990, 0xbff4fc1f999beca7, 0x3fe74af9b8a9018a, 0x2, 0x2, 0x0, 0x0)
        /Users/Shared/Development/git.urban4m.com/projects/AP/app-tiler/src/github.com/pebbe/go-proj-4/proj/proj.go:138 +0x157 fp=0xc2080e9a28 sp=0xc2080e98e8
    
    opened by rnix 4
  • go get v5 fails in go module mode

    go get v5 fails in go module mode

    hi,

    Following readme go get v5 fails:

    go get github.com/pebbe/go-proj-4/proj/v5: module github.com/pebbe/[email protected] found (v0.9.2), but does not contain package github.com/pebbe/go-proj-4/proj/v5
    

    the other repo works: go get github.com/pebbe/proj/v5

    opened by jackielii 2
  • Does not find proj-4 header and library with homebrew on OS X

    Does not find proj-4 header and library with homebrew on OS X

    I am using homebrew on my mac to maintain a few packages like proj-4 which installs all headers and libraries in /usr/local/{include,lib}. If I change the cgo directive to use pkg-config it will pick the location of the header files and libraries properly.

    diff --git a/proj/proj.go b/proj/proj.go index e451626..917383c 100644 --- a/proj/proj.go +++ b/proj/proj.go @@ -26,7 +26,7 @@ Example usage: package proj

    /* -#cgo LDFLAGS: -lproj +#cgo pkg-config: proj #include "proj.h" */ import "C"

    opened by jum 2
  • mercator projection with longitude 90 causes panic

    mercator projection with longitude 90 causes panic

    package main
    
    import (
        "fmt"
    
        "github.com/pebbe/go-proj-4/proj"
    )
    
    func main() {
        if merc, err := proj.NewProj("+proj=merc +ellps=clrk66 +lat_ts=33"); err != nil {
            fmt.Printf(
                "error getting mercator *proj.Proj: %s\n",
                err)
        } else if ll, err := proj.NewProj("+proj=latlong"); err != nil {
            fmt.Printf(
                "error getting ll *proj.Proj: %s\n",
                err)
        } else {
            long, lat := 90.0, -66.51326044311185
            if x, y, err := proj.Transform2(
                ll,
                merc,
                proj.DegToRad(lat),
                proj.DegToRad(long),
            ); err != nil {
                fmt.Printf(
                    "error making mercator projection: %s\n",
                    err)
            } else {
                fmt.Printf(
                    "success: (%f, %f)", x, y)
            }
    
        }
    }
    
    // Local Variables:
    // compile-cmd: "go run proj_transform2_bug.go"
    // End:
    
    opened by erjoalgo 2
  • tag new version for go1.12

    tag new version for go1.12

    in a go module project, just upgraded to go1.12 today and compile fails with

    ../../go/pkg/mod/github.com/pebbe/[email protected]/proj/proj.go:48:9: identifier "_Ctype_projPJ" may conflict with identifiers generated by cgo
    
    opened by jackielii 1
  • breakage for proj.4 4.8.0 -> 4.9.1?

    breakage for proj.4 4.8.0 -> 4.9.1?

    go-proj-4 [e.g., tests] work fine for proj.4 4.8.0 [circa march 2012] but fail for 4.9.1 [circa march 2015]. is go-proj-4 tracking proj releases? if yes, then this may be an unrelated os/userland proj packaging issue instead. if no, then see below.

    workaround unknown. notes follow: os: archlinux. using packaged proj. (4.8.0 works fine). have not tried installing proj 4.9.1 directly from source.

    $ go get -u github.com/pebbe/go-proj-4/proj $ cd github.com/pebbe/go-proj-4/proj $ proj Rel. 4.9.1, 04 March 2015 usage: proj [ -beEfiIlormsStTvVwW [args] ] [ +opts[=arg] ] [ files ] $ go test --- FAIL: TestMercToLatlong (0.00s) proj_test.go:18: major axis or radius = 0 or not given proj_test.go:23: projection is closed --- FAIL: TestInvalidErrorProblem (0.00s) proj_test.go:43: major axis or radius = 0 or not given FAIL exit status 1 FAIL github.com/pebbe/go-proj-4/proj 0.037s

    ls -l proj*

    -rw-r--r-- 1 root root 3156060 Dec 28 2013 proj-4.8.0-3-armv7h.pkg.tar.xz -rw-r--r-- 1 root root 3222600 Mar 13 10:25 proj-4.9.1-1-armv7h.pkg.tar.xz

    [downgrading package proj (4.9.1-1 => 4.8.0-3)] $ proj Rel. 4.8.0, 6 March 2012 usage: proj [ -beEfiIlormsStTvVwW [args] ] [ +opts[=arg] ] [ files ] $ go test PASS

    ok github.com/pebbe/go-proj-4/proj 0.032s

    reviewing https://trac.osgeo.org/proj/ https://svn.osgeo.org/metacrs/proj/trunk/proj/NEWS does not mention any 4.8 -> 4.9 incompatible changes?

    perhaps go-proj could expose [or at least test] pj_get_release() to clarify tracking / compatibility / issues with upstream proj-4. https://svn.osgeo.org/metacrs/proj/trunk/proj/src/pj_release.c: char const pj_release[]="Rel. 4.9.1, 04 March 2015";

    opened by peribothron 1
  • Feature request: Add support for EPSG

    Feature request: Add support for EPSG

    package main
    
    import (
        "fmt"
    
        "github.com/pebbe/go-proj-4/proj"
    )
    
    func main() {
        projs := []string{
            "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m [email protected] +wktext  +no_defs",
            "+proj=merc +ellps=clrk66 +lat_ts=33",
            "+init=EPSG:4326",
            "+init=EPSG:3857",
        }
        for _, def := range projs {
            NewProjMust(def)
        }
        // the EPSG projections fail to compile
    }
    func NewProjMust(spec string) *proj.Proj {
        if p, err := proj.NewProj(spec); err != nil {
            fmt.Printf("error creating projection from '%s': %s\n", spec, err.Error())
            return nil
        } else {
            return p
        }
    }
    
    // Local Variables:
    // compile-cmd: "go run proj_panic.go"
    // End:
    

    Result: the EPSG projections fail to compile

    opened by erjoalgo 1
  • : fatal error: 'proj_api.h' file not found

    : fatal error: 'proj_api.h' file not found

    go get github.com/pebbe/go-proj-4/proj

    # github.com/pebbe/go-proj-4/proj
    In file included from ../../../../github.com/pebbe/go-proj-4/proj/proj.go:30:
    ./proj.h:1:10: fatal error: 'proj_api.h' file not found
    #include <proj_api.h>
             ^
    1 error generated.
    
    opened by themihai 1
  • Define ACCEPT_USE_OF_DEPRECATED_PROJ_API_H

    Define ACCEPT_USE_OF_DEPRECATED_PROJ_API_H

    This is to avoid the following error:

    /usr/include/proj_api.h:37:2: error: #error 'To use the proj_api.h you must define the macro ACCEPT_USE_OF_DEPRECATED_PROJ_API_H'

    This is necessary when using proj version 6.0.0 onwards. See release notes here.

    opened by peterstace 0
  • What are the environment required for this installation project?

    What are the environment required for this installation project?

    An error was reported during this installation. What are the environment required for this installation project? # github.com/pebbe/go-proj-4/proj In file included from ..\..\github.com\pebbe\go-proj-4\proj\proj.go:33: ./proj.h:2:10: fatal error: proj_api.h: No such file or directory #include <proj_api.h> ^~~~~~~~~~~~ compilation terminated.

    opened by myhnuhai 2
Releases(v5.0.1)
Owner
Peter Kleiweg
Peter Kleiweg
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 246 Dec 30, 2022
Go (golang) wrapper for GDAL, the Geospatial Data Abstraction Library

------------- About ------------- The gdal.go package provides a go wrapper for GDAL, the Geospatial Data Abstraction Library. More information about

null 236 Dec 24, 2022
geoserver is a Go library for manipulating a GeoServer instance via the GeoServer REST API.

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/g

Hisham waleed karam 78 Dec 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.5k Dec 31, 2022
A library provides spatial data and geometric algorithms

Geoos Our organization spatial-go is officially established! The first open source project Geoos(Using Golang) provides spatial data and geometric alg

spatial-go 550 Dec 27, 2022
Efficient 2D geometry library for Go.

geometry An efficient 2D geometry library for Go. Features Point, Rect, Line, and Polygon geometry types Operations such as Intersects, Contains, and

Josh Baker 31 Dec 22, 2022
Go bindings for the PortAudio audio I/O library

portaudio This package provides an interface to the PortAudio audio I/O library. See the package documentation for details. To build this package you

Gordon Klaus 559 Jan 1, 2023
Go bindings for raylib, a simple and easy-to-use library to enjoy videogames programming.

raylib-go Golang bindings for raylib, a simple and easy-to-use library to enjoy videogames programming. Requirements Ubuntu X11 apt-get install libgl1

Milan Nikolic 915 Dec 28, 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
:traffic_light: Go bindings for libappindicator3 C library

go-appindicator Go bindings for libappindicator3 C library. Libappindicator is a library to allow applications to export a menu into the Unity Menu ba

Dawid Dziurla 20 Jun 19, 2022
GNU Aspell spell checking library bindings for Go (golang)

Aspell library bindings for Go GNU Aspell is a spell checking tool written in C/C++. This package provides simplified Aspell bindings for Go. It uses

Vladimir Sibirov 43 Nov 14, 2022
Go language bindings for the COIN-OR Linear Programming library

clp Description The clp package provides a Go interface to the COIN-OR Linear Programming (CLP) library, part of the COIN-OR (COmputational INfrastruc

Los Alamos National Laboratory 38 Nov 9, 2022
Go bindings for unarr (decompression library for RAR, TAR, ZIP and 7z archives)

go-unarr Golang bindings for the unarr library from sumatrapdf. unarr is a decompression library and CLI for RAR, TAR, ZIP and 7z archives. GoDoc See

Milan Nikolic 220 Dec 29, 2022
Go bindings for the snowball libstemmer library including porter 2

Go (golang) bindings for libstemmer This simple library provides Go (golang) bindings for the snowball libstemmer library including the popular porter

Richard Johnson 20 Sep 27, 2022
Upskirt markdown library bindings for Go

Goskirt Package goskirt provides Go-bindings for the excellent Sundown Markdown parser. (F/K/A Upskirt). To use goskirt, create a new Goskirt-value wi

Jukka-Pekka Kekkonen 32 Oct 23, 2022
This project provides Go bindings for nuklear.h — a small ANSI C GUI library.

Nuklear Package nk provides Go bindings for nuklear.h — a small ANSI C gui library. See github.com/vurtun/nuklear. All the binding code has automatica

null 1.5k Jan 1, 2023
Go4vl is Go library for working with the Video for Linux API (V4L2) natively, without any C bindings.

go4vl A Go library for working with the Video for Linux user API (V4L2). Gov4l hides all the complexities of working with V4L2 and exposes idiomatic G

Vladimir Vivien 143 Dec 23, 2022
Golang bindings for XCGUI, Windows GUI library, DirectUI design idea.

XCGUI 项目文档 帮助文档 程序示例 介绍 English | 简体中文 DirectUI设计思想: 在窗口内没有子窗口,界面元素都是逻辑上的区域(无HWND句柄,安全,灵活), 所有UI元素都是自主开发(不受系统限制), 更加灵活的实现各种程序界面,满足不同用户的需求.

twgh 224 Dec 22, 2022
redic - Bindings for hiredis Redis-client library

This repo is a fork of https://github.com/redis/hiredis. redic - Bindings for hiredis Redis-client Go library Install go get -u github.com/hjyoun0731/

null 0 Dec 21, 2021
Go-aspell - GNU Aspell spell checking library bindings for golang

Aspell library bindings for Go GNU Aspell is a spell checking tool written in C/

Vladimir Sibirov 43 Nov 14, 2022