无法写入GeoJSON数据的集合

时间:2019-03-29 08:20:00

标签: go geospatial geojson aerospike

我是Aerospike的新手,我使用的是go client,并且一直在尝试编写GeoJSON数据。

我可以单独编写geojson,但不能作为集合。

package main

import (

    "fmt"
    "github.com/onsi/ginkgo"


    "log"
    "github.com/onsi/gomega"
    _ "strings"

    as "github.com/aerospike/aerospike-client-go"
    shared "github.com/aerospike/aerospike-client-go/examples/shared"
)

func main() {
    runRecord_Entry(shared.Client)

    log.Println("\t \t Application ran successfully GrandMaster")
}

func runRecord_Entry(client *as.Client) {


    // define a client to connect to

    client, err := as.NewClient("127.0.0.1",3000)
    PanicOnError(err)

    ginkgo.It("To load the data", func() {
        // The Data
        points := []string{
            `{
            "type": "FeatureCollection",
            "features": [
                {
                    "type": "Feature",
                    "geometry" : {
                        "type" : "Point",
                        "coordinates": [13.009318762,80.003157854]
                    },
                    "properties" : {
                        "name" :"Work shop",
                        "demand":"49589",
                        "capacity":"4231"
                    }
                },
                {
                    "type": "Feature",
                    "geometry" : {
                        "type" : "Point",
                        "coordinates": [13.00961276, 80.003422154]
                    },
                    "properties" : {
                        "name" :"main block",
                        "demand":"247859",
                        "capacity":"2974"
                    }
                },
                {
                    "type": "Feature",
                    "geometry" : {
                        "type" : "Point",
                        "coordinates": [13.009318762,80.003157854]
                    },
                    "properties" : {
                        "name" :"Work shop",
                        "demand":"49589",
                        "capacity":"4231"
                    }
                },
                {
                    "type": "Feature",
                    "geometry" : {
                        "type" : "Point",
                        "coordinates": [13.00961276, 80.003422154]
                    },
                    "properties" : {
                        "name" :"main block",
                        "demand":"247859",
                        "capacity":"2974"
                    }
                }
            ]
            }`}

        // define some bins
        count := 0
        for i, ptsb := range points {

            key, _ := as.NewKey("test", "testset", i)
            bin := as.NewBin("vada", as.NewGeoJSONValue(ptsb))
            err := client.PutBins(shared.WritePolicy, key, bin)

            gomega.Expect(err).ToNot(gomega.HaveOccurred())
            shared.PanicOnError(err)

            count++

            gomega.Expect(count).To(gomega.Equal(4))
        }

        // queries only work on indices

        client.DropIndex(shared.WritePolicy, "test", "testset", "my_geo_inex_hu")
        client.CreateIndex(shared.WritePolicy, "test", "testset","ma_geo_index","gjsn","as.GEO2DSPHERE")


    })

    fmt.Println("\t \t \t \t The records are wriiten !!")

}

func runOptimal_Location(client *as.Client){}

func PanicOnError(err error){
    if err != nil{
        panic(err)
    }
}

运行kaiyaash.go

2019/03/29 13:45:41主持人:127.0.0.1

2019/03/29 13:45:41端口:3000

2019/03/29 13:45:41命名空间:测试

2019/03/29 13:45:41设置:测试集                  记录很糟糕!

2019/03/29 13:45:41应用程序成功运行GrandMaster

///我仍然找不到上面写在名称空间中的数据

0 个答案:

没有答案