func PeopleLD(request *restful.Request, response *restful.Response) { sprReturn := glSparqlCall2("foo") log.Printf("Data from sparql call:\n %v \n\n", sprReturn) // Now convert this to JSON-LD dataparsed, _ := jsonld.ParseDataset([]byte(sprReturn)) //log.Printf(dataparsed) jldOptions := jsonld.NewOptions("http://data.geolink.org") jsonldResults := jsonld.FromRDF(dataparsed, jldOptions) log.Printf("JSON-LD:\n %s\n\n", jsonldResults) // jldConext := jsonld.Context{context: geolinkContext} // jsonldCompacted, _ := jsonld.Compact(dataparsed, jldConext, jldOptions) // log.Printf("JSON-LD compacted:\n %s\n\n", jsonldCompacted) // Are these next three lines needed with X.Serialize() // jsonString, _ := json.Marshal(jsonldResults) // log.Println("JSON string for use in JSON-LD linter") // log.Println(string(jsonString)) //log.Printf("\nSerialized back to RDF:\n %s \n\n", dataparsed.Serialize()) //data := "place holder response string" response.WriteEntity(jsonldResults) }
func RectFeatures(request *restful.Request, response *restful.Response) { sprReturn := RectCall(request.QueryParameter("lat0"), request.QueryParameter("long0"), request.QueryParameter("lat1"), request.QueryParameter("long1"), request.QueryParameter("lat2"), request.QueryParameter("long2"), request.QueryParameter("lat3"), request.QueryParameter("long3")) dataparsed, _ := jsonld.ParseDataset([]byte(sprReturn)) jldOptions := jsonld.NewOptions("http://data.geolink.org") jsonldResults := jsonld.FromRDF(dataparsed, jldOptions) response.WriteEntity(jsonldResults) }
func DrillingFeatures(request *restful.Request, response *restful.Response) { sprReturn := DrillingCall(request.QueryParameter("lat"), request.QueryParameter("long"), request.QueryParameter("radius")) dataparsed, _ := jsonld.ParseDataset([]byte(sprReturn)) jldOptions := jsonld.NewOptions("http://data.oceandrilling.org") jsonldResults := jsonld.FromRDF(dataparsed, jldOptions) // todo resolve how (if I need to) insert context here // jldConext := jsonld.Context{context: geolinkContext} // jsonldCompacted, _ := jsonld.Compact(dataparsed, jldConext, jldOptions) // log.Printf("JSON-LD compacted:\n %s\n\n", jsonldCompacted) response.WriteEntity(jsonldResults) }
func ContainerDrillSites(request *restful.Request, response *restful.Response) { sprReturn := ContainerDrillSitesCall() if strings.Contains(sprReturn, "# Empty NT") { response.WriteHeader(http.StatusNoContent) } else { dataparsed, error := jsonld.ParseDataset([]byte(sprReturn)) if error != nil { response.WriteEntity("Need JSON error / emptry string here for panic situation") } jldOptions := jsonld.NewOptions("http://data.geolink.org") jsonldResults := jsonld.FromRDF(dataparsed, jldOptions) response.WriteEntity(jsonldResults) } }
// use web arch error codes? 204 No Content // Is the best error from the JSON-LD lib really a strings contains check? func WKTPoly(request *restful.Request, response *restful.Response) { sprReturn := WKTPolyCall(request.QueryParameter("g")) if strings.Contains(sprReturn, "# Empty NT") { // response.mimetype JSON response.WriteHeader(http.StatusNoContent) //response.WriteEntity(errorJSON) // not setting to JSON } else { dataparsed, error := jsonld.ParseDataset([]byte(sprReturn)) if error != nil { response.WriteEntity("Need JSON error / emptry string here for panic situation") } jldOptions := jsonld.NewOptions("http://data.geolink.org") jsonldResults := jsonld.FromRDF(dataparsed, jldOptions) response.WriteEntity(jsonldResults) } }