Невозможно записать коллекцию данных GeoJSON - PullRequest
0 голосов
/ 29 марта 2019

Я новичок в аэроспайке, я использую Go-клиент и пытаюсь записать данные 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

// до сих пор не могу найти вышеуказанные данные, записанные в пространстве имен

...