A library provides spatial data and geometric algorithms

Overview

Geoos

Our organization spatial-go is officially established! The first open source project Geoos(Using Golang) provides spatial data and geometric algorithms. All comments and suggestions are welcome!

Guides

http://www.spatial-go.com

Contents

Structure

  1. Algorithm is the definition of spatial operation, which is outside exposing.
  2. strategy.go defines the implementation of the spatial computing based algorithm.

Documentation

How to use Geoos: Example: Calculating area via Geoos

package main

import (
  "encoding/json"
  "fmt"
  "github.com/spatial-go/geoos"
  "github.com/spatial-go/geoos/encoding/wkt"
  "github.com/spatial-go/geoos/geojson"
  "github.com/spatial-go/geoos/planar"
)

func main() {
  // First, choose the default algorithm.
  strategy := planar.NormalStrategy()
  // Secondly, manufacturing test data and convert it to geometry
  const polygon = `POLYGON((-1 -1, 1 -1, 1 1, -1 1, -1 -1))`
  geometry, _ := wkt.UnmarshalString(polygon)
  // Last, call the Area () method and get result.
  area, e := strategy.Area(geometry)
  if e != nil {
    fmt.Printf(e.Error())
  }
  fmt.Printf("%f", area)
  // get result 4.0

  rawJSON := []byte(`
  { "type": "FeatureCollection",
  "features": [
    { "type": "Feature",
    "geometry": {"type": "Point", "coordinates": [102.0, 0.5]},
    "properties": {"prop0": "value0"}
    }
  ]
  }`)

  fc := geojson.NewFeatureCollection()
  _ = json.Unmarshal(rawJSON, &fc)
  println("%p", fc)

  // Geometry will be unmarshalled into the correct geo.Geometry type.
  point := fc.Features[0].Geometry.(geoos.Point)
  println("%p", &point)

}

Maintainer

@spatial-go

Contributing

We will also uphold the concept of "openness, co-creation, and win-win" to contribute in the field of space computing.

Welcome to join us !please report an issue

Email Address: [email protected]

License

Geoos is licensed under the: LGPL-2.1

Comments
  • 发现一个几何图形相交判断bug

    发现一个几何图形相交判断bug

    const a1 = "LINESTRING (119.3039141328787309 26.0688567207556332, 119.3036083610503510 26.0681869226817753, 119.3033186824765153 26.0679845368985639)" const a2 = "POLYGON ((119.3172630350001100 26.0702955380000390, 119.3172497400000793 26.0703321550000737, 119.3172290960000055 26.0703549800000474, 119.3171979140000758 26.0703685560000622, 119.3171192560000691 26.0703590920000465, 119.3150906640000812 26.0699619740000230, 119.3149878960000478 26.0699494980000281, 119.3143222760000981 26.0698098000000300, 119.3139883680000821 26.0697879690000605, 119.3132765640000343 26.0697358590000476, 119.3132011550001153 26.0697304560000589, 119.3129190370000288 26.0697096750000696, 119.3111563600000409 26.0695852310000760, 119.3109965890000694 26.0695196390000774, 119.3107551660000354 26.0694689840000251, 119.3106054270000413 26.0694540860000643, 119.3105945770000744 26.0694530400000417, 119.3105856270000231 26.0694516730000601, 119.3105761370001119 26.0694508760000758, 119.3105671780000421 26.0694500390000599, 119.3105579580001177 26.0694489820000399, 119.3105487380000795 26.0694481760000372, 119.3105397880000282 26.0694470890000503, 119.3105305480000879 26.0694462820000581, 119.3105216080000446 26.0694454650000580, 119.3105123880000065 26.0694443880000790, 119.3105031680000820 26.0694435710000789, 119.3104942080000228 26.0694427650000762, 119.3104849880000984 26.0694416580000734, 119.3104681690000461 26.0694400640000481, 119.3104369790000874 26.0694370640000557, 119.3103078550000191 26.0693934490000743, 119.3102112770000076 26.0693755690000444, 119.3099221230000921 26.0693252120000238, 119.3088639410000269 26.0691093130000695, 119.3086276680000992 26.0690527240000733, 119.3084014460000617 26.0689920200000529, 119.3078483490000963 26.0688210030000391, 119.3075865890000387 26.0687429470000325, 119.3073801560000220 26.0686865570000350, 119.3070351180000443 26.0685920170000713, 119.3069911800000682 26.0685800900000686, 119.3069032920000154 26.0685624780000467, 119.3066070560000753 26.0685197070000640, 119.3064738660000330 26.0685132670000712, 119.3055648530000781 26.0684864910000442, 119.3053117620000876 26.0684792470000275, 119.3007346390000976 26.0683380540000371, 119.3006188190000785 26.0683266760000265, 119.3005433790000325 26.0683196640000574, 119.3005168190001086 26.0683183240000744, 119.3001297180001075 26.0682964810000612, 119.2996200020000970 26.0682958950000625, 119.2993834490000609 26.0683003320000353, 119.2991243780001014 26.0682819690000542, 119.2983976580001126 26.0682839130000730, 119.2981323310000334 26.0683084390000772, 119.2977460480000218 26.0683579540000778, 119.2974045160000287 26.0684075110000322, 119.2965745140000990 26.0685377980000226, 119.2957896610000716 26.0685491330000332, 119.2954264850000072 26.0685515730000361, 119.2948474920000308 26.0685097760000417, 119.2948101140000290 26.0686241440000686, 119.2953998390000834 26.0686505420000572, 119.2958137050001142 26.0686534930000562, 119.2965880250000055 26.0686596380000424, 119.2974137140000721 26.0685480800000278, 119.2977308180001046 26.0684904100000381, 119.2981231100000059 26.0684443940000392, 119.2983781080000654 26.0684130890000461, 119.2990806990001147 26.0684019210000315, 119.2993546810000680 26.0684102540000708, 119.2995790230000921 26.0684185770000454, 119.3000887390001026 26.0684145510000462, 119.3005572210000764 26.0684423330000641, 119.3005629010000348 26.0684431410000457, 119.3006383100000676 26.0684536950000734, 119.3006567700000460 26.0684561280000366, 119.3006977290000350 26.0684620840000321, 119.3007180780000454 26.0684740200000533, 119.3007218740000326 26.0684981680000760, 119.3053149980000853 26.0686393630000453, 119.3055637490000436 26.0686441480000326, 119.3064667840000084 26.0686581810000462, 119.3065940230001161 26.0686689850000448, 119.3067073910000317 26.0686865780000403, 119.3068311080000967 26.0687150200000701, 119.3069512740000846 26.0687434730000405, 119.3069881630000282 26.0687543130000563, 119.3073364600001014 26.0688575640000408, 119.3074984030000678 26.0689052580000293, 119.3077775230000270 26.0689833080000426, 119.3085641160000705 26.0691944590000730, 119.3088245570000936 26.0692634930000509, 119.3104337000000896 26.0695586580000622, 119.3104681500000197 26.0695621660000256, 119.3105988980000802 26.0695759610000550, 119.3107415770000443 26.0695908320000740, 119.3109618480000336 26.0696518090000495, 119.3111069680001037 26.0697228380000752, 119.3128978550000738 26.0698554030000764, 119.3131954130000167 26.0698761580000564, 119.3132700220000970 26.0698810410000306, 119.3139812860000575 26.0699304300000563, 119.3143030130000852 26.0699590790000570, 119.3149478770000087 26.0700692340000728, 119.3150706170000603 26.0700736100000654, 119.3170849910001152 26.0704565680000542, 119.3172141570000804 26.0705490010000744, 119.3172494210000423 26.0705875310000579, 119.3172630350001100 26.0702955380000390))"

    g1, _ := wkt.UnmarshalString(a1)
    g2, _ := wkt.UnmarshalString(a2)
    f, _ := strategy.Intersects(g1, g2)
    fmt.Println(f)
    

    返回结果为false,实际情况是有相交 1660797569318

    opened by ziyunhai 4
  • Is there a bug on BufferInMeter?

    Is there a bug on BufferInMeter?

    1. When I used the method on polygon, the result is not what I want.
    2. Remove the following code maybe more suitable or accurate? (reference postgis st_buffer and turf.js)
    centroid := geom.Centroid()
    width = measure.MercatorDistance(width, centroid.Lat())
    
    opened by jarcoug 4
  • A problem of  the method space.Contains()

    A problem of the method space.Contains()

    While using the method space.Contains() to determine whether Geometry A contains Geometry B,I found that in some cases the result returned is not as expected. The code is as follows:

    type TestStruct struct {
    	name    string
    	args    args
    	want    bool
    	wantErr bool
    }
    func TestAlgorithm_Contains(t *testing.T) {
    	const polygon1 = `POLYGON((1 1,5 1,5 5,1 5,1 1))`
    	const polygon2 = `POLYGON((2 2,3 2,3 3,2 3,2 2))`
    
    	p1, _ := wkt.UnmarshalString(polygon1)
    	p2, _ := wkt.UnmarshalString(polygon2)
    
    	tests := []TestStruct{
    		{name: "contain", args: args{
    			g1: p1,
    			g2: p2,
    		}, want: true, wantErr: false},
    	}
    
    	for _, tt := range tests {
    		t.Run(tt.name, func(t *testing.T) {
    			G := NormalStrategy()
    			got, err := G.Contains(tt.args.g1, tt.args.g2) // got = true
    			if (err != nil) != tt.wantErr {
    				t.Errorf("Contains() error = %v, wantErr %v", err, tt.wantErr)
    				return
    			}
    			if got != tt.want {
    				t.Errorf("Contains() got = %v, want %v", got, tt.want)
    			}
    		})
    	}
    }
    

    and the corresponding image is

    image-20220118212319961

    obviously it is correct.

    But when I change the parameters, where polygon1 = POLYGON((113.48581807062143 23.33621329259057,113.48785155569199 23.336383160940287,113.48792833916376 23.335028970144833,113.48582512451681 23.33493907732756,113.48581807062143 23.33621329259057)) and polygon2 = POLYGON((113.48668269733025 23.335774475286513,113.48720314737876 23.3358047169134,113.4873120145494 23.335572135724533,113.48676140749377 23.33538486387792,113.48668269733025 23.335774475286513)),the result returned is false,but it should actually be true, as the image shows:

    image-20220118213111364

    I want to judge whether a POLYGON A contains another POLYGON B, but the result returned by this method does not match the actual one, or is there another more suitable way to judge? Hope someone can answer my doubts,thank you very much.

    opened by Mamba2Yi 4
  • An issue of PolygonOverlay.Union()

    An issue of PolygonOverlay.Union()

    When I used PolygonOverlay.Union() to find the union of two POLYGON, the result returned was as follows, which is different from the result I expected.

    image-20220310114034258

    The union I understand should be the result of the following.

    image-20220310114121711
    func TestPolygonOverlay_Union(t *testing.T) {
    	type fields struct {
    		PointOverlay  *PointOverlay
    		subjectPlane  *Plane
    		clippingPlane *Plane
    	}
    	tests := []struct {
    		name    string
    		fields  fields
    		want    []matrix.Steric
    		wantErr bool
    	}{
    		{"poly poly", fields{PointOverlay: &PointOverlay{matrix.PolygonMatrix{{{0, 0}, {10, 0}, {10, 10}, {0, 10}, {0, 0}}},
    			matrix.PolygonMatrix{{{5, 5}, {15, 5}, {15, 15}, {5, 15}, {5, 5}}},
    		}},
    			[]matrix.Steric{matrix.PolygonMatrix{{{5, 10}, {0, 10}, {0, 0}, {10, 0}, {10, 5}, {15, 5}, {15, 15}, {5, 15}, {5, 10}}}}, false},
    	}
    	for _, tt := range tests {
    		if !geoos.GeoosTestTag && tt.name != "poly poly03" {
    			continue
    		}
    		t.Run(tt.name, func(t *testing.T) {
    			p := &PolygonOverlay{
    				PointOverlay:  tt.fields.PointOverlay,
    				subjectPlane:  tt.fields.subjectPlane,
    				clippingPlane: tt.fields.clippingPlane,
    			}
    			got, err := p.Union()
                             // result:
                             // POLYGON((0 0,15 0,15 15,0 15,0 0))
          
                             // want: 
                             // POLYGON ((10 0, 0 0, 0 10, 5 10, 5 15, 15 15, 15 5, 10 5, 10 0))     
    			if (err != nil) != tt.wantErr {
    				t.Errorf("PolygonOverlay.Union() error = %v, wantErr %v", err, tt.wantErr)
    				return
    			}
    			// ...
    		})
    	}
    }
    
    opened by Mamba2Yi 3
  • a problem of distanceLineAndLine

    a problem of distanceLineAndLine

    	line0 := space.LineString{{116.40495300292967, 39.926785883895654}, {116.3975715637207, 39.9295502919}}
    	line1 := space.LineString{{116.37310981750488, 39.92099342895789}, {116.39928817749023, 39.9174387253541}}
    	fmt.Println(line1.Distance(line0))
    
    0 <nil>
    
    

    dist is initialized with 0, this for impossible in if distP, _ := elem.Distance(); dist > distP { dist = distP }

    var dist float64 modified with var dist float64 = math.MaxFloat64

    
    修改问题源码
    func (el *ElementDistance) distanceLineAndLine() (float64, error) {
    	var dist float64 
    	if mark := relate.IsIntersectionEdge(el.From.(matrix.LineMatrix), el.To.(matrix.LineMatrix)); mark {
    		return 0, nil
    	}
    	for _, v := range el.From.(matrix.LineMatrix) {
    		elem := &ElementDistance{matrix.Matrix(v), el.To, el.F}
    		if distP, _ := elem.Distance(); dist > distP {
    			dist = distP
    		}
    	}
    	return dist, nil
    }
    
    opened by radi2015 2
  • feat: 增加 Geobuf 编解码

    feat: 增加 Geobuf 编解码

    Geobuf 将 GeoJSON 数据几乎无损地压缩到协议缓冲区中。与单独使用 GeoJSON 相比的优势:

    1. 非常紧凑:通常使 GeoJSON 小 6-8 倍。即使比较 gzip 压缩后的大小,也小 2-2.5 倍。
    2. 非常快的编码和解码——甚至比原生 JSON 解析/字符串化还要快。
    3. 可以容纳任何 GeoJSON 数据,包括具有任意属性的扩展。
    opened by aichibazhang 1
  • The result of function

    The result of function "Intersection" is wrong.

    I call function "Intersection" for compute intersection of two geometries, but the result maybe wrong. case 1

    20210927102727

    polygon01, _ := wkt.UnmarshalString("POLYGON ((111.30523681640625 38.11727165830543, 112.34344482421875 38.11727165830543, 112.34344482421875 38.89103282648846, 111.30523681640625 38.89103282648846, 111.30523681640625 38.11727165830543))")
    polygon02, _ := wkt.UnmarshalString("POLYGON ((111.50848388671875 37.6359849542696, 112.64007568359375 37.6359849542696, 112.64007568359375 38.35027253825765, 111.50848388671875 38.35027253825765, 111.50848388671875 37.6359849542696))")
    G := NormalStrategy()
    got, err := G.Intersection(polygon01, polygon02)
    // got is nil
    

    case 2

    tapd_54316281_base64_1632645422_42

    linestring, _ := wkt.UnmarshalString("LINESTRING (111.98638916015625 38.50357937743225, 111.96372985839844 38.42723559654225, 111.91085815429688 38.344887442462806, 111.87309265136717 38.24680876017446, 111.84906005859375 38.15075747130226)")
    polygon, _ := wkt.UnmarshalString("POLYGON ((112.01248168945312 38.4519755295767, 111.7096710205078 38.39441521865825, 111.90948486328125 38.176671418717746, 112.01248168945312 38.4519755295767))")
    G := NormalStrategy()
    got, err := G.Intersection(linestring, polygon)
    // got is 'MULTIPOINT((111.96859688870947 38.44363360825604),(111.86710034242763 38.22285924285058))'
    // but correct result maybe like this 'LINESTRING(111.968596888709 38.443633608256,111.963729858398 38.4272355965423,111.910858154297 38.3448874424628,111.873092651367 38.2468087601745,111.867100342428 38.2228592428506)'
    
    bug 
    opened by zhyt1985 1
  • New filter method in GeoOS version 1.0.2

    New filter method in GeoOS version 1.0.2

    We will add a filter method to the spatial validity check method. Can help you correct some of the invalid positions of the filter geometry.

    Thanks for your support 🙏

    opened by pipipizhuqaq 1
  • The shadow method Transformer.transformCollection   prevents space.Geometry.Simplify() to work correctly

    The shadow method Transformer.transformCollection prevents space.Geometry.Simplify() to work correctly

    Using DP geometry simplification I noted that the shadow method tranformCollection() in Tranformer obscure the call at a missing method in DPTransformer and the call at space.Geometry.Simplify() doesn't work in case of geometry collection. I suppose the following method has to be added for DPTransformer.

    func (d *DPTransformer) transformCollection(geom matrix.Collection, parent matrix.Steric) matrix.Steric {
    	transGeoms := matrix.Collection{}
    	for _, v := range geom {
    		transformGeom, _ := d.Transform(v)
    		if transformGeom == nil {
    			continue
    		}
    		if d.pruneEmptyGeometry && transformGeom.IsEmpty() {
    			continue
    		}
    		transGeoms = append(transGeoms, transformGeom)
    	}
    	return transGeoms
    }
    
    opened by andreacomparini 0
  • 发现一个图形计算的bug,对两个multiloygon进行union操作时,得到错误的计算结果

    发现一个图形计算的bug,对两个multiloygon进行union操作时,得到错误的计算结果

    第一个multipolyon:[[[[116.458553 39.88791] [116.45857094384326 39.88790553563427] [116.45856 39.88788] [116.4585554 39.887848] [116.45856448239947 39.88781221907734] [116.4587112 39.8878347] [116.4591606 39.8878296] [116.45952 39.8878296] [116.45987912842851 39.887820731401185] [116.4598813171811 39.88786572522166] [116.46016837242065 39.88786341614056] [116.4601663 39.8877617] [116.4602998 39.8877604] [116.46066780447438 39.887752718692184] [116.4606703 39.8878119] [116.4606736 39.8878444] [116.46067457705385 39.88785934421506] [116.460966 39.887857] [116.4610304829428 39.88785653927355] [116.4610285 39.8877514] [116.46124888556602 39.88774876594252] [116.46143624152896 39.8877471103319] [116.46144 39.88792] [116.46144 39.88813] [116.46162616602014 39.88812731264462] [116.46162644189089 39.88813614050829] [116.461844 39.888133] [116.462701 39.888107] [116.46288437670745 39.88810507620295] [116.46289951156183 39.88810521663731] [116.46289532422891 39.88857001059088] [116.4629 39.88877] [116.46290002476694 39.88885143029087] [116.46290295416163 39.88902060283474] [116.4629017869734 39.889185567331936] [116.46290084263367 39.889185576001445] [116.46289971814569 39.889344502074465] [116.46273834940025 39.88934400268843] [116.462497 39.889345] [116.46248448325267 39.889345124362634] [116.46248426575583 39.88936692289501] [116.46248073326008 39.88936695799271] [116.461774 39.88936] [116.46176887366315 39.88925767831632] [116.46165 39.88926071363079] [116.46147137010163 39.88926000543263] [116.46147137010163 39.889328505081636] [116.46128 39.88933] [116.46128 39.88938087151887] [116.46106 39.88938000041751] [116.46106 39.889386707395175] [116.46104787153232 39.88938665937188] [116.46104741421834 39.88938050047763] [116.4609066 39.8893861] [116.46081 39.88939] [116.46075 39.88939] [116.46051 39.8894] [116.4604 39.8894] [116.46001 39.88941] [116.45977 39.88942] [116.45964 39.88943] [116.4593013 39.8894392] [116.45863305962509 39.889449950776175] [116.45863182188327 39.889413562334404] [116.45864 39.88925] [116.45864 39.88919] [116.45867 39.88908] [116.45870000018292 39.88904999987805] [116.45873 39.88903] [116.45879557236869 39.88896442771095] [116.458585 39.888791] [116.45861712636355 39.88853572565184] [116.45862172063282 39.88849707042791] [116.45859959426923 39.88849534476924] [116.45861503309332 39.88836544569761] [116.4586208207688 39.88828984423715] [116.45862073675784 39.88828973863373] [116.4586294031725 39.88817653337766] [116.458631 39.888143] [116.458617 39.888064] [116.458553 39.88791]]]] 第二个multipolygon:[[[[116.46277925748878 39.88599] [116.46327 39.88599] [116.46327121548828 39.886109220211566] [116.46431140000675 39.88610711457489] [116.46437815770724 39.88610553470714] [116.46437821516655 39.88610675825216] [116.46437798719191 39.886019937380794] [116.46449012423405 39.88601728357566] [116.465193 39.886019] [116.46520508527627 39.886019012615826] [116.465205 39.886002] [116.46584660810673 39.886000300375876] [116.46595733806026 39.88599648210394] [116.46595682983767 39.88595148862629] [116.466 39.88595] [116.46663 39.88595] [116.4671 39.88594] [116.46709942832697 39.88589866765154] [116.467261 39.885898] [116.46726128624843 39.88594] [116.4679 39.88594] [116.46805881008105 39.88595684350834] [116.468043 39.886048] [116.46815974241039 39.886054984588654] [116.46815777083641 39.88607577565319] [116.46815788779723 39.886075783508765] [116.46815384274812 39.88611558570732] [116.468129 39.886114] [116.46792 39.886295] [116.467879 39.88629483526067] [116.467879 39.886422] [116.467864 39.886578] [116.46784403501898 39.88657731712968] [116.467839 39.886627] [116.4678267404138 39.886723675594055] [116.46778 39.88672] [116.4677801555936 39.886717277112126] [116.46764 39.886712] [116.467014 39.886706] [116.46692 39.886765] [116.466925 39.887255] [116.467228 39.887255] [116.467557 39.887252] [116.46770983916338 39.88726160836621] [116.46769 39.88746] [116.46768690541188 39.88767971575692] [116.46771 39.88768] [116.467711 39.887696] [116.46770801472468 39.88823533974078] [116.46767156440872 39.88823507456137] [116.46761 39.88871] [116.46761 39.88878] [116.46761473983558 39.88888860676638] [116.46760846016662 39.88888874291529] [116.46749545690462 39.88887846989132] [116.46749783782663 39.88886234889874] [116.467406 39.888854] [116.46562163217507 39.888857145646234] [116.46513720883907 39.888850509710124] [116.46513646130968 39.88889586425838] [116.465099 39.891529] [116.46509902876262 39.89152985233281] [116.46509382233967 39.89164750296356] [116.46505847429681 39.89164644112512] [116.46505 39.89166] [116.46504218543848 39.89218357562194] [116.46439781209806 39.892186892859215] [116.46437700037785 39.8921867880231] [116.46437799934012 39.891626370191105] [116.46433003220054 39.89162612856142] [116.46432913903807 39.89154727507503] [116.46418 39.89154] [116.46402 39.89153] [116.46402131828314 39.891488080779375] [116.463751 39.891482] [116.46374671152233 39.891513895753334] [116.4635903 39.8915009] [116.46338 39.89145] [116.4632133 39.8913735] [116.4630362 39.8912531] [116.46301444387001 39.89121807797685] [116.46296532973061 39.891141337364424] [116.4629665 39.8911409] [116.4629477 39.8910689] [116.462941 39.8909845] [116.4629343 39.8908868] [116.4629263 39.8907324] [116.4629142 39.8903707] [116.4629082 39.8900314] [116.4629076 39.8899751] [116.4629047 39.8897277] [116.4629065 39.8896535] [116.4629060377541 39.889344521631685] [116.46289971817896 39.88934449737274] [116.46290084273836 39.889185559645384] [116.4629017869734 39.889185567331936] [116.46290295416163 39.88902060283474] [116.4629 39.88885] [116.4629 39.88877] [116.46289532422891 39.88857001059088] [116.462902 39.887829] [116.46290193254518 39.88782389379261] [116.4628762206468 39.887823976702784] [116.46287400232684 39.88782366764997] [116.46287476934253 39.8877141122413] [116.46287 39.88752] [116.46287 39.88711] [116.4628600101224 39.88647064783323] [116.46278 39.88647] [116.46278 39.8861] [116.46277925748878 39.88599]]]]

    opened by herozhi 2
  • 发现一个缓冲区分析bug

    发现一个缓冲区分析bug

    
    const d = `{"type":"LineString","coordinates":[[148.3,23.9],[149.3,25],[149.5,25.3],[149.5,25.3],[149.5,25.3],[149.9,26.1],[150.2,26.4],[150.5,27.1],[150.5,27.1],[150.8,28.8],[150.8,28.8],[150.9,29.2],[150.7,29.7],[150.8,30.1],[150.6,30.4],[150.4,30.6],[150.1,31.6],[149.8,32.5]]}`
    g, _ := geoencoding.Decode([]byte(d), geoencoding.GeoJSON)
    b := g.BufferInMeter(100, calc.QuadrantSegments)
    fmt.Println(string(geoencoding.Encode(b, geoencoding.WKT)))
    
    

    返回结果中存在很多NaN,返回结果如下:

    POLYGON((149.29921586139045 25.000588113059923,NaN NaN,149.4990720118337 25.30037798677464,149.89907201183368 26.100375455240716,149.89914706649813 26.100498760295352,149.899242
    28147618 26.100610276338013,150.19924228147616 26.40060870255267,NaN NaN,150.4989943229493 27.100139551904082,NaN NaN,150.79900567017944 28.800190521518022,150.8990056701794 29.
    20018978565512,150.69903881583426 29.699709188528097,150.69899396085847 29.699865864360323,150.69898265359106 29.70002701287475,150.69900527108788 29.700187260352127,150.7990052
    7108794 30.10018651010826,150.59911798315972 30.399561890373853,150.3992289238104 30.59942813752714,150.39909781968294 30.59959441563601,150.3990141831927 30.599782033025665,150
    .09901418319268 31.599784315923866,149.79902051880478 32.4997666111684,149.79898535265346 32.49993225733657,149.79898917883068 32.500100506508375,149.79903185029852 32.500264892
    96596,149.79911172721646 32.500419099468,149.79922573995933 32.500557200011805,149.79936950708134 32.500673887556204,149.79953750369262 32.50076467795526,149.79972327377766 32.5
    0082608226746,149.79991967829622 32.50085574082134,149.8001191695328 32.500852513886876,149.80031408115107 32.50081652546986,149.80049692280687 32.50074915854693,149.80066066799
    785 32.50065300192449,149.80079902408818 32.50053175076223,149.8009066741309 32.500390064583456,149.8009794811952 32.50023338822593,150.10097948119522 31.600235694878712,150.100
    9858168073 31.60021568357662,150.40098581680732 30.60021796648385,150.6007710761896 30.40057303614954,150.60088201684027 30.40043810766075,150.80088201684026 30.100439447496502,
    150.8009600570297 30.100292430107576,150.8010056916988 30.100135541888058,150.80101738050664 30.099974078368952,150.80099472891214 30.099813489539766,150.70099472891212 29.69981
    2739298796,150.9009611841657 29.200292247081364,150.90100613383842 29.200134258372675,150.90101730742316 29.199971762339494,150.90099432982058 29.199810213993548,NaN NaN,150.801
    00567705074 28.799862627877324,NaN NaN,150.50095058750804 27.099676147743672,150.20095058750803 26.399674147279168,150.20086862381865 26.399524804326035,150.2007577185238 26.399
    39129423718,149.9007577185238 26.09938972047752,NaN NaN,149.5008714400348 25.299524557295143,149.3008714400348 24.999523387088384,149.30078413860957 24.999411884125102,148.30078
    413860957 23.89940672780346,148.30064247505413 23.899278266075022,148.30047612154266 23.899177540150923,148.30029147094731 23.899108420940394,148.30009561928694 23.8990735647080
    93,148.29989609303098 23.899074310987338,148.29970055986155 23.899110631098452,148.29951653400875 23.89918112925092,148.29935108748282 23.89928309618727,148.29921057830106 23.89
    9412613306403,148.29910040615243 23.8995647032637,148.2990248048909 23.899733521258984,148.2989866798305 23.899912579659166,148.29898749609595 23.900094997322515,148.29902722231
    86 23.900273764041103,148.29910433184202 23.900442009939216,148.29921586139045 23.900593269474307,149.29921586139045 25.000588113059923))
    
    
    opened by ziyunhai 0
  • Added polygon dissovle method

    Added polygon dissovle method

    This algorithm takes a vector layer and combines their features into new features. One or more attributes can be specified to dissolve features belonging to the same class (having the same value for the specified attributes), alternatively all features can be dissolved in a single one. All output geometries will be converted to multi geometries. In case the input is a polygon layer, common boundaries of adjacent polygons being dissolved will get erased.

    opened by pipipizhuqaq 0
Releases(v1.1.3)
Package kml provides convenince methods for creating and writing KML documents.

go-kml Package kml provides convenience methods for creating and writing KML documents. Key Features Simple API for building arbitrarily complex KML d

Tom Payne 66 Jul 29, 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 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
Go package to quick and easy create json data in geojson format.

#GEOJSON Go package to easy and quick create datastructure which can be serialized to geojson format INSTALLATION $ go get github.com/kpawlik/geojson

Kris Pawlik 50 Jun 6, 2022
Geometry/geography library in Go, DEPRECATED, use ->

go.geo (deprecated) Go.geo is a geometry/geography library in Go. The primary use case is GIS geometry manipulation on the server side vs. in the brow

Paul Mach 321 Jan 2, 2023
Go bindings for the Cartographic Projections Library PROJ.4

The Go package proj provides a limited interface to the Cartographic Projections Library PROJ. For PROJ version 5 and beyond, see also: https://github

Peter Kleiweg 42 Nov 10, 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
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
Encoding and decoding GeoJSON <-> Go

go.geojson Go.geojson is a package for encoding and decoding GeoJSON into Go structs. Supports both the json.Marshaler and json.Unmarshaler interfaces

Paul Mach 228 Jan 2, 2023
Package polyline implements a Google Maps Encoding Polyline encoder and decoder.

go-polyline Package polyline implements a Google Maps Encoding Polyline encoder and decoder. Encoding example func ExampleEncodeCoords() { coords :=

Tom Payne 79 Dec 1, 2022
Types and utilities for working with 2d geometry in Golang

orb Package orb defines a set of types for working with 2d geo and planar/projected geometric data in Golang. There are a set of sub-packages that use

Paul Mach 610 Dec 28, 2022
Real-time Geospatial and Geofencing

Tile38 is an open source (MIT licensed), in-memory geolocation data store, spatial index, and realtime geofence. It supports a variety of object types

Josh Baker 8.4k Dec 30, 2022
Reproducing images with geometric primitives.

Primitive Pictures Reproducing images with geometric primitives. How it Works A target image is provided as input. The algorithm tries to find the sin

Michael Fogleman 12.1k Dec 31, 2022
Golang Sequel ORM that support Enum, JSON, Spatial and many more

sqlike A golang SQL ORM which anti toxic query and focus on latest features. Installation go get github.com/si3nloong/sqlike Fully compatible with nat

SianLoong 20 Nov 21, 2022
Turn any key/value index into a high-performance two-dimensional spatial index

modular-spatial-index For the demo that this animated gif was generated from

SequentialRead.com 5 Mar 6, 2022
Golang string comparison and edit distance algorithms library, featuring : Levenshtein, LCS, Hamming, Damerau levenshtein (OSA and Adjacent transpositions algorithms), Jaro-Winkler, Cosine, etc...

Go-edlib : Edit distance and string comparison library Golang string comparison and edit distance algorithms library featuring : Levenshtein, LCS, Ham

Hugo Bollon 373 Dec 20, 2022
Golang string comparison and edit distance algorithms library, featuring : Levenshtein, LCS, Hamming, Damerau levenshtein (OSA and Adjacent transpositions algorithms), Jaro-Winkler, Cosine, etc...

Go-edlib : Edit distance and string comparison library Golang string comparison and edit distance algorithms library featuring : Levenshtein, LCS, Ham

Hugo Bollon 373 Dec 20, 2022
Go translations of the algorithms and clients in the textbook Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

Overview Go translations of the Java source code for the algorithms and clients in the textbook Algorithms, 4th Edition by Robert Sedgewick and Kevin

youngzy 175 Dec 13, 2022
Data structure and relevant algorithms for extremely fast prefix/fuzzy string searching.

Trie Data structure and relevant algorithms for extremely fast prefix/fuzzy string searching. Usage Create a Trie with: t := trie.New() Add Keys with:

Derek Parker 623 Dec 27, 2022