示例#1
0
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)
}
示例#2
0
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)
}
示例#3
0
文件: jsonld.go 项目: dennwc/cayley
// NewReaderFromMap returns quad reader for JSON-LD map object.
func NewReaderFromMap(o interface{}) *Reader {
	data, err := gojsonld.ToRDF(o, gojsonld.NewOptions(""))
	if err != nil {
		return &Reader{err: err}
	}
	return &Reader{
		graphs: data.Graphs,
	}
}
示例#4
0
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)
}
示例#5
0
文件: jsonld.go 项目: dennwc/cayley
func (w *Writer) Close() error {
	opts := gojsonld.NewOptions("")
	var data interface{}
	data = gojsonld.FromRDF(w.ds, opts)
	if w.ctx != nil {
		out, err := gojsonld.Compact(data, w.ctx, opts)
		if err != nil {
			return err
		}
		data = out
	}
	return json.NewEncoder(w.w).Encode(data)
}
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)
	}
}
示例#7
0
// 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)
	}

}