I’m able to add individual geojson data but not a collection package main
import (
"fmt"
"log"
_ "strings"
as "github.com/aerospike/aerospike-client-go"
shared "github.com/aerospike/aerospike-client-go/examples/shared"
) func main() { runRecord_Entry(shared.Client) runOptimal_Location(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)
//key, err := as.NewKey("test","testset","dert")
//key, _ := as.NewKey("test", "testset", "mapkey")
PanicOnError(err)
//binName := "gjsn"
// queries only work on indices
//client.DropIndex("writepolicy", "jolar", "jolardest", "set+binName")
// The Data
// 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
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)
// write the bins
//client.PutBins(shared.WritePolicy, key, bin)
//client.PutBins(shared.WritePolicy, key, bin)
//record, err := client.Get(shared.Policy, key, binName)
shared.PanicOnError(err)
}
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) } }
The output , go run zarpin.go 2019/03/28 07:52:39 hosts: 127.0.0.1 2019/03/28 07:52:39 port: 3000 2019/03/28 07:52:39 namespace: test 2019/03/28 07:52:39 set: testset 2019/03/28 07:52:39 Invalid GeoJSON on insert/update
I’ve posted the same in a different section of the forum where the pointed the error may be in server. Thanks in advance !!