Skip to content

Commit a32e069

Browse files
committed
Cleaned up geojson demo
1 parent cb2967a commit a32e069

File tree

1 file changed

+3
-166
lines changed

1 file changed

+3
-166
lines changed

docs/demos/leaflet-graphql/index.html

Lines changed: 3 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,6 @@ <h3>Edit GraphQL Query</h3>
111111
// const GRAPHQL_URL = 'http://localhost:8642/graphql';
112112
const GRAPHQL_URL = 'https://rpt.demo.aksw.org/graphql';
113113

114-
// GraphQL query
115-
116-
117114
const simpleQuery = `
118115
query countries
119116
@prefix(map: {
@@ -142,7 +139,6 @@ <h3>Edit GraphQL Query</h3>
142139
}
143140
`;
144141

145-
146142
const complexQuery = `
147143
query countries
148144
@prefix(map: {
@@ -153,7 +149,7 @@ <h3>Edit GraphQL Query</h3>
153149
coy: "https://schema.coypu.org/global#",
154150
afn: "http://jena.apache.org/ARQ/function#"})
155151
{
156-
locations(limit: 1000) @pattern(of: "?s a coy:Country") {
152+
locations(limit: 100) @pattern(of: "?s a coy:Country") {
157153
type @bind(of: "'Feature'")
158154
properties {
159155
style {
@@ -175,6 +171,8 @@ <h3>Edit GraphQL Query</h3>
175171
FILTER(?p NOT IN (rdfs:label))
176172
}
177173
# Auto-derive property cardinalities from all data
174+
# Use the 'service enhancer' cache extension to cache
175+
# the cardinalities
178176
{ SERVICE <cache:> {
179177
{ SELECT ?p (MAX(?c) AS ?pc) {
180178
SELECT ?x ?p (COUNT(*) AS ?c) {
@@ -195,169 +193,8 @@ <h3>Edit GraphQL Query</h3>
195193
}
196194
`;
197195

198-
const complexQueryOld2 = `
199-
{
200-
locations(limit: 1000)
201-
@pattern(of: "?s a coy:Country", from: "s", to: "s")
202-
@prefix(name: "", iri: "https://schema.coypu.org/global#")
203-
@prefix(name: "rdfs", iri: "http://www.w3.org/2000/01/rdf-schema#")
204-
@prefix(name: "geo", iri: "http://www.opengis.net/ont/geosparql#")
205-
@prefix(name: "geof", iri: "http://www.opengis.net/def/function/geosparql/")
206-
@prefix(name: "norse", iri: "https://w3id.org/aksw/norse#")
207-
@prefix(name: "afn", iri: "http://jena.apache.org/ARQ/function#")
208-
@prefix(name: "coy", iri: "https://schema.coypu.org/global#")
209-
{
210-
type @one @pattern(of: "BIND(?x AS ?xx) BIND('Feature' AS ?y)", from: "x", to: "y")
211-
212-
# Properties container
213-
properties @one @pattern(of: "BIND(?x AS ?y)", from: "x", to: "y") {
214-
215-
# Style
216-
style @one @pattern(of: """
217-
BIND(?x as ?y)
218-
BIND(CONCAT('#', SUBSTR(MD5(STR(?x)), 1, 6)) AS ?color)
219-
BIND(norse:json.object("fillColor", ?color) AS ?json)
220-
""", from: "x", to: "json")
221-
222-
223-
label @one
224-
@pattern(of: """
225-
SELECT ?s ?o {
226-
?s rdfs:label ?o .
227-
FILTER(langMatches(lang(?o), 'en'))
228-
}
229-
""", from: "s", to: "o")
230-
231-
features
232-
@pattern(of: """
233-
SELECT * {
234-
{
235-
?s ?p ?o .
236-
FILTER(?p NOT IN (rdfs:label))
237-
}
238-
# Auto-derive property cardinalities from all data
239-
{ SERVICE <cache:> {
240-
{ SELECT ?p (MAX(?c) AS ?pc) {
241-
SELECT ?x ?p (COUNT(*) AS ?c) {
242-
?x ?p ?z
243-
} GROUP BY ?x ?p
244-
} GROUP BY ?p }
245-
}
246-
}
247-
}
248-
""", from: "s", to: "o")
249-
@index(by: "afn:localname(?p)", oneIf: "?pc = 1")
250-
}
251-
252-
# Geometry Section
253-
geometry @one
254-
@pattern(of: """
255-
?s geo:hasGeometry/geo:asWKT ?x .
256-
BIND(STRDT(STR(geof:asGeoJSON(
257-
geof:simplifyDp(?x, 0.2)
258-
)), norse:json) AS ?o)
259-
""", from: "s", to: "o")
260-
}
261-
}
262-
`;
263-
264-
265-
266-
267-
268-
269-
const simpleQueryOld = `
270-
{
271-
locations(limit: 10)
272-
@pattern(of: "?s a coy:Country", from: "s", to: "s")
273-
@prefix(name: "rdfs", iri: "http://www.w3.org/2000/01/rdf-schema#")
274-
@prefix(name: "geo", iri: "http://www.opengis.net/ont/geosparql#")
275-
@prefix(name: "geof", iri: "http://www.opengis.net/def/function/geosparql/")
276-
@prefix(name: "norse", iri: "https://w3id.org/aksw/norse#")
277-
@prefix(name: "coy", iri: "https://schema.coypu.org/global#")
278-
{
279-
label @one
280-
@pattern(of: """
281-
SELECT ?s ?o {
282-
?s rdfs:label ?o .
283-
FILTER(langMatches(lang(?o), 'en'))
284-
}
285-
""", from: "s", to: "o")
286-
287-
# Note: simplifyDp simplifies polygons on query time
288-
# Reduces amount of data and thus loading time
289-
geometry @one
290-
@pattern(of: """
291-
?s geo:hasGeometry/geo:asWKT ?x .
292-
BIND(STRDT(STR(geof:asGeoJSON(
293-
geof:simplifyDp(?x, 0.2)
294-
)), norse:json) AS ?o)
295-
""", from: "s", to: "o")
296-
}
297-
}
298-
`;
299-
300-
const complexQueryOld = `
301-
{
302-
locations(limit: 1000)
303-
@pattern(of: "?s a coy:Country", from: "s", to: "s")
304-
@prefix(name: "", iri: "https://schema.coypu.org/global#")
305-
@prefix(name: "rdfs", iri: "http://www.w3.org/2000/01/rdf-schema#")
306-
@prefix(name: "geo", iri: "http://www.opengis.net/ont/geosparql#")
307-
@prefix(name: "geof", iri: "http://www.opengis.net/def/function/geosparql/")
308-
@prefix(name: "norse", iri: "https://w3id.org/aksw/norse#")
309-
@prefix(name: "afn", iri: "http://jena.apache.org/ARQ/function#")
310-
@prefix(name: "coy", iri: "https://schema.coypu.org/global#")
311-
{
312-
label @one
313-
@pattern(of: """
314-
SELECT ?s ?o {
315-
?s rdfs:label ?o .
316-
FILTER(langMatches(lang(?o), 'en'))
317-
}
318-
""", from: "s", to: "o")
319-
320-
features
321-
@pattern(of: """
322-
SELECT * {
323-
{
324-
?s ?p ?o .
325-
FILTER(?p NOT IN (rdfs:label))
326-
}
327-
# Auto-derive property cardinalities from all data
328-
{ SERVICE <cache:> {
329-
{ SELECT ?p (MAX(?c) AS ?pc) {
330-
SELECT ?x ?p (COUNT(*) AS ?c) {
331-
?x ?p ?z
332-
} GROUP BY ?x ?p
333-
} GROUP BY ?p }
334-
}
335-
}
336-
}
337-
""", from: "s", to: "o")
338-
@index(by: "afn:localname(?p)", oneIf: "?pc = 1")
339-
340-
geometry @one
341-
@pattern(of: """
342-
?s geo:hasGeometry/geo:asWKT ?x .
343-
BIND(STRDT(STR(geof:asGeoJSON(
344-
geof:simplifyDp(?x, 0.2)
345-
)), norse:json) AS ?o)
346-
""", from: "s", to: "o")
347-
}
348-
}
349-
`;
350-
351-
/**
352-
There is currently a bug with variable analysis which breaks indexing labels by language...
353-
#label @pattern(of: "?s rdfs:label ?o", from: "s", to: "o") @one {
354-
# labelByLang @pattern(of: "BIND(?x AS ?y)", from: "x", to: "y") # @index(by: "lang(?y)", oneIf: "true") @one
355-
#}
356-
*/
357-
358196
const initialQuery = simpleQuery;
359197

360-
361198
// Initialize the Leaflet map
362199
const map = L.map('map').setView([0, 0], 2);
363200

0 commit comments

Comments
 (0)