forked from mthh/covikoa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rules-generation-rules.ttl
992 lines (886 loc) · 41.6 KB
/
rules-generation-rules.ttl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix cvk-ir: <http://example.com/cvk-ir#> .
@prefix gviz: <http://lig-tdcge.imag.fr/steamer/covikoa/geoviz#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix cvkd: <http://lig-tdcge.imag.fr/steamer/covikoa/derivation#> .
@prefix afn: <http://jena.apache.org/ARQ/function#> .
cvkd:RuleGenerationDerivationRuleWithEntrypointAndPathToGVA
a sh:NodeShape ;
rdfs:comment """Prepare the SHACL derivation rules which will be used to create the intermediate representation of the
individuals from the semantic data model to be portrayed."""@en ;
sh:targetClass gviz:GeoVisualApplication ;
sh:rule [ a sh:SPARQLRule ;
sh:construct """
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix gviz: <http://lig-tdcge.imag.fr/steamer/covikoa/geoviz#>
prefix geo: <http://www.opengis.net/ont/geosparql#>
prefix geof: <http://www.opengis.net/def/function/geosparql/>
prefix sh: <http://www.w3.org/ns/shacl#>
prefix cvkd: <http://lig-tdcge.imag.fr/steamer/covikoa/derivation#>
prefix ir: <http://example.com/cvk-ir#>
CONSTRUCT {
?uriThisRule
a sh:NodeShape, cvkd:DerivationRule ;
sh:targetSubjectsOf cvkd:represents ;
sh:rule [ a sh:SPARQLRule ;
sh:construct ?ruleContent ;
] .
} WHERE {
?protoapp rdfs:subClassOf gviz:GeoVisualApplication ;
cvkd:represents ?entrypointconcept .
?app a ?protoapp ;
cvkd:represents ?entrypoint .
{
SELECT DISTINCT ?pathFromGVA ?conceptGVR ?concept WHERE {
?conceptGVR a owl:Class ;
rdfs:subClassOf gviz:GeoVisualIntermediateRepresentation ;
cvkd:pathFromGVA ?pathFromGVA ;
cvkd:represents ?concept .
}
}
BIND(
URI(
CONCAT(
"http://lig-tdcge.imag.fr/steamer/covikoa/derivation#",
replace(STR(?conceptGVR), STR("http://example.com/cvk-ir#"), ""),
"-DerivationRule-",
STRUUID()
)
) as ?uriThisRule) .
[] a cvkd:PrefixToInject ;
rdf:value ?pfxs .
BIND(CONCAT(\"\"\"
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix gviz: <http://lig-tdcge.imag.fr/steamer/covikoa/geoviz#>
prefix cvkd: <http://lig-tdcge.imag.fr/steamer/covikoa/derivation#>
prefix owl: <http://www.w3.org/2002/07/owl#> \n\"\"\",
str(?pfxs), \"\"\"
CONSTRUCT {
?thisIndiv a $this ;
gviz:represents ?u .
} WHERE {
$this rdfs:subClassOf gviz:GeoVisualIntermediateRepresentation ;
cvkd:represents \"\"\", "<", STR(?concept), ">", \"\"\" .
?u a \"\"\", "<", STR(?concept), ">", \"\"\" .
NOT EXISTS { ?_ gviz:represents ?u . }
\"\"\",
\"\"\"<\"\"\", STR(?entrypoint), \"\"\"> \"\"\", cvkd:RewriteShaclPropertyPathToSPARQLPropertyPath(?pathFromGVA), \"\"\" ?u .\"\"\",
\"\"\"
BIND(URI(CONCAT("urn:id:",STRUUID())) as ?thisIndiv) .
}
\"\"\") as ?ruleContent ).
}
""" ;
] .
# TODO ? If the application defines an individual as entryPoint but does not provide the path to reach it..
#cvkd:RuleGenerationDerivationRuleWithEntrypointButNoPathToGVA
# a sh:NodeShape ;
# sh:targetClass gviz:GeoVisualApplication ;
cvkd:RuleGenerationDerivationRuleNoEntrypointNoPathFromGVA
a sh:NodeShape ;
rdfs:comment """Prepare the SHACL derivation rules which will be used to create the intermediate representation of the
individuals from the semantic data model to be portrayed
when there is no "entrypoint" defined."""@en ;
sh:targetClass gviz:GeoVisualApplication ;
sh:rule [ a sh:SPARQLRule ;
sh:construct """
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix gviz: <http://lig-tdcge.imag.fr/steamer/covikoa/geoviz#>
prefix geo: <http://www.opengis.net/ont/geosparql#>
prefix geof: <http://www.opengis.net/def/function/geosparql/>
prefix sh: <http://www.w3.org/ns/shacl#>
prefix cvkd: <http://lig-tdcge.imag.fr/steamer/covikoa/derivation#>
prefix ir: <http://example.com/cvk-ir#>
CONSTRUCT {
?uriThisRule
a sh:NodeShape, cvkd:DerivationRule ;
sh:targetSubjectsOf cvkd:represents ;
sh:rule [ a sh:SPARQLRule ;
sh:construct ?ruleContent ;
] .
} WHERE {
?app rdf:type/rdfs:subClassOf* gviz:GeoVisualApplication .
FILTER (NOT EXISTS {
?app cvkd:represents ?entrypoint .
})
{
SELECT DISTINCT ?conceptGVR ?concept WHERE {
?conceptGVR a owl:Class ;
rdfs:subClassOf gviz:GeoVisualIntermediateRepresentation ;
cvkd:represents ?concept .
}
}
BIND(
URI(
CONCAT(
"http://lig-tdcge.imag.fr/steamer/covikoa/derivation#",
replace(STR(?conceptGVR), STR("http://example.com/cvk-ir#"), ""),
"-DerivationRule-",
STRUUID()
)
) as ?uriThisRule) .
[] a cvkd:PrefixToInject ;
rdf:value ?pfxs .
BIND(CONCAT(\"\"\"
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix gviz: <http://lig-tdcge.imag.fr/steamer/covikoa/geoviz#>
prefix cvkd: <http://lig-tdcge.imag.fr/steamer/covikoa/derivation#>
prefix owl: <http://www.w3.org/2002/07/owl#> \n\"\"\",
str(?pfxs), \"\"\"
CONSTRUCT {
?thisIndiv a $this ;
gviz:represents ?u .
} WHERE {
$this rdfs:subClassOf gviz:GeoVisualIntermediateRepresentation ;
cvkd:represents \"\"\", "<", STR(?concept), ">", \"\"\" .
?u a \"\"\", "<", STR(?concept), ">", \"\"\" .
NOT EXISTS { ?_ gviz:represents ?u . }
BIND(URI(CONCAT("urn:id:",STRUUID())) as ?thisIndiv) .
}
\"\"\") as ?ruleContent ).
}
""" ;
] .
cvkd:RuleGenerationEnrichmentRules
a sh:NodeShape ;
rdfs:comment """Prepare the various enrichment rules for gviz:PortrayalRules that do not link to a TemplateSymbolizer ."""@en ;
sh:targetSubjectsOf cvkd:denotesGVR;
sh:rule [ a sh:SPARQLRule ;
sh:construct """
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix afn: <http://jena.apache.org/ARQ/function#>
prefix gviz: <http://lig-tdcge.imag.fr/steamer/covikoa/geoviz#>
prefix geo: <http://www.opengis.net/ont/geosparql#>
prefix geof: <http://www.opengis.net/def/function/geosparql/>
prefix sh: <http://www.w3.org/ns/shacl#>
prefix cvkd: <http://lig-tdcge.imag.fr/steamer/covikoa/derivation#>
CONSTRUCT {
?thisIndiv a sh:NodeShape , ?typeRule ;
sh:targetClass ?conceptGVR ;
sh:rule [ a sh:SPARQLRule ;
sh:construct ?constructValue ;
] .
} WHERE {
?conceptGVR rdfs:subClassOf gviz:GeoVisualIntermediateRepresentation ;
cvkd:represents ?someConcept .
$this cvkd:denotesGVR ?conceptGVR ;
gviz:hasPortrayalRule ?rule .
OPTIONAL {
$this cvkd:multipleGeometryType ?_multGeomType .
}
BIND(IF(Bound(?_multGeomType) && ?_multGeomType = true, true, false) as ?multipleGeomType)
# we generate one shacl rule of this type for each gviz:PortrayalRule that has symbolizer
FILTER (EXISTS { ?rule gviz:hasSymbol/<https://gis.lu.se/ont/data_portrayal/symbolizer#hasSymbolizer> ?symbolizer . })
FILTER (NOT EXISTS { ?rule gviz:hasSymbol/<https://gis.lu.se/ont/data_portrayal/symbolizer#hasTemplateSymbolizer> ?symbolizer . })
# Is there PropertyConstraint on this PortrayalRule ?
OPTIONAL {
?rule cvkd:hasPropertyConstraint ?propConstraint .
}
# Is there SpatialConstraint on this PortrayalRule ?
OPTIONAL {
?rule cvkd:hasSpatialConstraint ?spatialConstraint .
OPTIONAL {
?spatialConstraint cvkd:preludeBinding ?spatialConstraintPreBindings .
}
}
# Is there a TransformOperation on the Portrayal or on the PortrayalRule ?
OPTIONAL {
$this cvkd:hasTransformOperation [ cvkd:preludeBinding ?preTransformOperationPortrayal ] .
}
OPTIONAL {
$this cvkd:hasTransformOperation ?transformOperationPortrayal .
}
OPTIONAL {
?rule cvkd:hasTransformOperation [ cvkd:preludeBinding ?preTransformOperationRule ] .
}
OPTIONAL {
$this cvkd:hasTransformOperation ?transformOperationRule .
}
BIND(IF(BOUND(?preTransformOperationRule), ?preTransformOperationRule, ?preTransformOperationPortrayal) as ?preTransformOperation)
BIND(IF(BOUND(?transformOperationRule), ?transformOperationRule, ?transformOperationPortrayal) as ?transformOperation)
OPTIONAL {
$this cvkd:hasSPARQLFilter [
rdfs:label ?nameConditionFilter ;
rdf:value ?contentConditionFilter ;
] .
}
OPTIONAL {
$this gviz:onComponent ?compo .
?compo a ?compoType .
FILTER(?compoType in (gviz:Map2dComponent, gviz:Map3dComponent))
}
# Prepare the type of rule between DefaultEnrichmentRule and ProblemSpecificEnrichmentRule
BIND(
IF(
BOUND(?contentConditionFilter),
cvkd:ProblemSpecificEnrichmentRule,
cvkd:DefaultEnrichmentRule
) as ?typeRule) .
# Prepare the IRI for this enrichment rule
BIND(
URI(
CONCAT(
"http://lig-tdcge.imag.fr/steamer/covikoa/derivation#",
replace(STR($this), STR("http://example.com/cvk-ir#"), ""),
"-EnrichmentRule-",
STRUUID()
)
) as ?thisIndiv) .
[] a cvkd:PrefixToInject ;
rdf:value ?pfxs .
# Prepare the value for the sh:construct predicate
BIND(CONCAT(
\"\"\"
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix geo: <http://www.opengis.net/ont/geosparql#>
prefix geof: <http://www.opengis.net/def/function/geosparql/>
prefix prov: <http://www.w3.org/ns/prov#>
prefix scale: <https://gis.lu.se/ont/visualisation_scale#>
prefix ion: <http://lig-tdcge.imag.fr/steamer/covikoa/interaction#>
prefix gviz: <http://lig-tdcge.imag.fr/steamer/covikoa/geoviz#>
prefix cvkd: <http://lig-tdcge.imag.fr/steamer/covikoa/derivation#> \n\"\"\",
str(?pfxs), \"\"\"
CONSTRUCT {
$this gviz:hasMaterialisation ?materialisation .
?materialisation
geo:hasGeometry [ geo:asWKT ?resGeom ] ;
gviz:isSymbolizedBy ?symblz ;
gviz:displayIndex ?di;
prov:wasGeneratedBy <\"\"\", STR(?thisIndiv), \"\"\"> ;
prov:qualifiedGeneration ?gen ;
scale:hasScale ?scale ;
gviz:appearsIn ?component ;
cvkd:fromPortrayalRule ?rule .
?component gviz:presentsGVR $this .
} WHERE {
NOT EXISTS { $this gviz:hasMaterialisation [ prov:wasGeneratedBy <\"\"\", STR(?thisIndiv), \"\"\"> ; ] . }
BIND(<\"\"\", STR($this), \"\"\"> as ?portrayal) .
# TODO: simplify the next line ...
BIND(\"\"\", IF(isBlank(?rule), CONCAT(\"\"\"<_:\"\"\", afn:bnode(?rule), \"\"\">\"\"\"), CONCAT(\"\"\"<\"\"\", STR(?rule), \"\"\">\"\"\")), \"\"\" as ?rule) .
?portrayal cvkd:denotesGVR ?thisKind ;
gviz:hasPortrayalRule ?rule .
?rule gviz:hasSymbol/<https://gis.lu.se/ont/data_portrayal/symbolizer#hasSymbolizer> ?symblz .
OPTIONAL { ?rule cvkd:hasPropertyConstraint ?propConstraint . }
$this a ?thisKind ;
gviz:represents ?somethingRepresentable .
\"\"\",
IF(BOUND(?contentConditionFilter), CONCAT(\"\"\"\n{\n\"\"\", STR(?contentConditionFilter), \"\"\"\n}\n\"\"\"), \"\"\"\"\"\"),
\"\"\"
BIND(cvkd:UnPackGeomWKT(?somethingRepresentable) as ?thisGeometry).
\"\"\",
IF(BOUND(?spatialConstraint), cvkd:RewriteSpatialConstraint_TODO(?spatialConstraint), \"\"\"\"\"\"),
IF(BOUND(?preTransformOperation), CONCAT(\"\"\" \"\"\", ?preTransformOperation), \"\"\"\"\"\"),
IF(BOUND(?transformOperation), CONCAT(\"\"\"\n BIND(\"\"\", cvkd:RewriteTransformOperationAsLiteral(?transformOperation), \"\"\" as ?newGeom)\n\"\"\"), \"\"\"\"\"\"),
IF(BOUND(?propConstraint), cvkd:RewritePropertyConstraint(?propConstraint, ?someConcept), \"\"\"\"\"\"),
IF(?multipleGeomType = true, \"\"\"
BIND(cvkd:UnpackGeomTypeFeature(?somethingRepresentable) as ?geomType) .
FILTER ( EXISTS { ?symblz a [ <https://gis.lu.se/ont/data_portrayal/symbolizer#defaultGeometryType> ?geomType ; ]. } )\"\"\", \"\"\"\"\"\"),
\"\"\"
OPTIONAL { ?portrayal gviz:displayIndex ?displayIndexPortrayal . }
OPTIONAL { ?rule gviz:displayIndex ?displayIndexRule . }
BIND(
IF(BOUND(?displayIndexRule),
?displayIndexRule,
IF(BOUND(?displayIndexPortrayal), ?displayIndexPortrayal, 500))
as ?di) .
# Fetch the scale information, might have be defined on
# each PortrayalRule or on the Portrayal using it
OPTIONAL { ?portrayal scale:hasScale ?pScale . }
OPTIONAL { ?rule scale:hasScale ?rScale . }
BIND(IF(BOUND(?rScale), ?rScale, ?pScale) as ?scale).
BIND(IF(BOUND(?newGeom), ?newGeom, ?thisGeometry) as ?resGeom) .
BIND(cvkd:GetCurrentGenerationNode() as ?gen) .\"\"\",
IF(BOUND(?compo),
CONCAT(\"\"\"\n BIND(<\"\"\", STR(?compo), \"\"\"> as ?component).\n\"\"\"),
\"\"\"\n ?app gviz:hasGeoVisualComponent ?component .\n ?component a gviz:Map2dComponent .\n\"\"\"
),
\"\"\"
BIND(IRI(CONCAT("urn:materialisation:id:", STRUUID())) as ?materialisation) .
}
\"\"\"
) as ?constructValue) .
}
""" ;
] .
#####
# TextSymbolizer
#####
cvkd:RuleCreationTextSymbolizerFromTemplateSymbolizer
a sh:NodeShape ;
rdfs:comment """Prepare the symbolizer (specific to a feature) from the provided template symbolizers."""@en ;
sh:targetSubjectsOf cvkd:denotesGVR ;
sh:rule [ a sh:SPARQLRule ;
sh:construct """
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix afn: <http://jena.apache.org/ARQ/function#>
prefix gviz: <http://lig-tdcge.imag.fr/steamer/covikoa/geoviz#>
prefix geo: <http://www.opengis.net/ont/geosparql#>
prefix geof: <http://www.opengis.net/def/function/geosparql/>
prefix sh: <http://www.w3.org/ns/shacl#>
prefix cvkd: <http://lig-tdcge.imag.fr/steamer/covikoa/derivation#>
prefix graphic: <https://gis.lu.se/ont/data_portrayal/graphic#>
CONSTRUCT {
?thisIndiv a sh:NodeShape , cvkd:SymbolizerCreationRule ;
sh:targetClass ?conceptGVR ; # TODO
sh:rule [ a sh:SPARQLRule ;
sh:construct ?constructValue ;
] .
} WHERE {
?conceptGVR rdfs:subClassOf gviz:GeoVisualIntermediateRepresentation ;
cvkd:represents ?someConcept .
$this cvkd:denotesGVR ?conceptGVR ;
gviz:hasPortrayalRule ?rule .
# for now we generate one shacl rule for each TemplateSymbolizer to derive..
FILTER (EXISTS { ?rule gviz:hasSymbol/<https://gis.lu.se/ont/data_portrayal/symbolizer#hasTemplateSymbolizer> ?templateSymbolizer . })
?templateSymbolizer a <https://gis.lu.se/ont/data_portrayal/symbolizer#TemplateTextSymbolizer> .
# Possible customisable properties here, the other ones in the constructed rule
OPTIONAL {
?templateSymbolizer graphic:hasFont/graphic:fontSize ?symblzFontSize .
OPTIONAL { ?symblzFontSize cvkd:valueOnProperty ?symblzFontSizeCustomisableGraphicValue . }
OPTIONAL { ?symblzFontSize cvkd:formula ?symblzFontSizeCustomisableGraphicValueFormula . }
}
OPTIONAL {
?templateSymbolizer graphic:textLabel ?symblzTextLabel .
OPTIONAL { ?symblzTextLabel cvkd:valueOnProperty ?symblzTextLabelCustomisableGraphicValue . }
}
# Is there PropertyConstraint on this PortrayalRule ?
OPTIONAL {
?rule cvkd:hasPropertyConstraint ?propConstraint .
}
# Is there SpatialConstraint on this PortrayalRule ?
OPTIONAL {
?rule cvkd:hasSpatialConstraint ?spatialConstraint .
OPTIONAL {
?spatialConstraint cvkd:preludeBinding ?spatialConstraintPreBindings .
}
}
OPTIONAL {
$this cvkd:hasSPARQLFilter [
rdfs:label ?nameConditionFilter ;
rdf:value ?contentConditionFilter ;
] .
}
# Prepare the IRI for this symbolizer creation rule
BIND(
URI(
CONCAT(
"http://lig-tdcge.imag.fr/steamer/covikoa/derivation#",
replace(STR($this), STR("http://example.com/cvk-ir#"), ""),
"-TextSymbolizerCreationRule-",
STRUUID()
)
) as ?thisIndiv) .
[] a cvkd:PrefixToInject ;
rdf:value ?pfxs .
# Prepare the value for the sh:construct predicate
BIND(CONCAT(
\"\"\"
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix geo: <http://www.opengis.net/ont/geosparql#>
prefix geof: <http://www.opengis.net/def/function/geosparql/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix prov: <http://www.w3.org/ns/prov#>
prefix afn: <http://jena.apache.org/ARQ/function#>
prefix scale: <https://gis.lu.se/ont/visualisation_scale#>
prefix ion: <http://lig-tdcge.imag.fr/steamer/covikoa/interaction#>
prefix gviz: <http://lig-tdcge.imag.fr/steamer/covikoa/geoviz#>
prefix graphic: <https://gis.lu.se/ont/data_portrayal/graphic#>
prefix symblzr: <https://gis.lu.se/ont/data_portrayal/symbolizer#>
prefix cvkd: <http://lig-tdcge.imag.fr/steamer/covikoa/derivation#> \n\"\"\",
str(?pfxs), \"\"\"
CONSTRUCT {
?symblz a symblzr:TextSymbolizer .
?symblz graphic:hasHalo ?halo .
?symblz graphic:hasFont [
graphic:fontFamily ?symblzFontFamily ;
graphic:fontSize ?symblzFontSize ;
graphic:fontWeight ?symblzFontWeight ;
] .
?symblz graphic:hasFill [
graphic:fillColor ?symblzFillColor ;
] .
?symblz graphic:textLabel ?symblzTextLabel .
} WHERE {
FILTER NOT EXISTS { ?symblz a symblzr:TextSymbolizer . }
BIND(<\"\"\", STR($this), \"\"\"> as ?portrayal) .
# TODO: simplify the next line ...
BIND(\"\"\", IF(isBlank(?rule), CONCAT(\"\"\"<_:\"\"\", afn:bnode(?rule), \"\"\">\"\"\"), CONCAT(\"\"\"<\"\"\", STR(?rule), \"\"\">\"\"\")), \"\"\" as ?rule) .
?portrayal cvkd:denotesGVR ?thisKind ;
gviz:hasPortrayalRule ?rule .
?rule gviz:hasSymbol/<https://gis.lu.se/ont/data_portrayal/symbolizer#hasTemplateSymbolizer> ?templateSymbolizer .
?templateSymbolizer a <https://gis.lu.se/ont/data_portrayal/symbolizer#TemplateTextSymbolizer> .
OPTIONAL { ?rule cvkd:hasPropertyConstraint ?propConstraint . }
OPTIONAL { ?templateSymbolizer graphic:hasFont/graphic:fontFamily ?symblzFontFamily . }
OPTIONAL { ?templateSymbolizer graphic:hasFont/graphic:fontWeight ?symblzFontWeight . }
OPTIONAL { ?templateSymbolizer graphic:hasFill/graphic:fillColor ?symblzFillColor . }
OPTIONAL { ?templateSymbolizer graphic:hasHalo ?halo . }
$this a ?thisKind ;
gviz:represents ?somethingRepresentable .
\"\"\",
IF(BOUND(?spatialConstraint), CONCAT(\"\"\" BIND(cvkd:UnPackGeomWKT(?somethingRepresentable) as ?thisGeometry)\n\"\"\", cvkd:RewriteSpatialConstraint_TODO(?spatialConstraint)), \"\"\"\"\"\"),
IF(BOUND(?contentConditionFilter), CONCAT(\"\"\"\n{\n\"\"\", STR(?contentConditionFilter), \"\"\"\n}\n\"\"\"), \"\"\"\"\"\"),
IF(BOUND(?propConstraint), cvkd:RewritePropertyConstraint(?propConstraint, ?someConcept), \"\"\"\"\"\"),
IF(!ISLITERAL(?symblzTextLabel),
CONCAT(\"\"\" ?somethingRepresentable \"\"\", cvkd:RewriteShaclPropertyPathToSPARQLPropertyPath(?symblzTextLabelCustomisableGraphicValue), \"\"\" ?symblzTextLabel . \n\"\"\"),
CONCAT(\"\"\" BIND(\\"\"\"\", STR(?symblzTextLabel), \"\"\"\\" as ?symblzTextLabel) . \n\"\"\")),
IF(!ISLITERAL(?symblzFontSize),
CONCAT(\"\"\" ?somethingRepresentable \"\"\", cvkd:RewriteShaclPropertyPathToSPARQLPropertyPath(?symblzFontSizeCustomisableGraphicValue), \"\"\" ?_symblzFontSize . \n\"\"\"),
CONCAT(\"\"\" BIND(\\"\"\"\", STR(?symblzFontSize), \"\"\"\\"^^xsd:decimal as ?_symblzFontSize) . \n\"\"\")),
IF(BOUND(?symblzFontSizeCustomisableGraphicValueFormula),
CONCAT(\"\"\" BIND((\"\"\", REPLACE(STR(?symblzFontSizeCustomisableGraphicValueFormula), "value", "_symblzFontSize"), \"\"\") as ?symblzFontSize) .\"\"\"),
\"\"\" BIND(?_symblzFontSize as ?symblzFontSize) .\"\"\"),
\"\"\"
BIND(IRI(CONCAT("urn:symbolizer:id:", afn:localname(?somethingRepresentable), "-", afn:localname(?templateSymbolizer))) as ?symblz) .
}\"\"\"
) as ?constructValue) .
}""" ;
] .
#####
# PointSymbolizer
#####
cvkd:RuleCreationPointSymbolizerFromTemplateSymbolizer
a sh:NodeShape ;
rdfs:comment """Prepare the symbolizer (specific to a feature) from the provided template symbolizers."""@en ;
sh:targetSubjectsOf cvkd:denotesGVR ;
sh:rule [ a sh:SPARQLRule ;
sh:construct """
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix afn: <http://jena.apache.org/ARQ/function#>
prefix gviz: <http://lig-tdcge.imag.fr/steamer/covikoa/geoviz#>
prefix graphic: <https://gis.lu.se/ont/data_portrayal/graphic#>
prefix geo: <http://www.opengis.net/ont/geosparql#>
prefix geof: <http://www.opengis.net/def/function/geosparql/>
prefix sh: <http://www.w3.org/ns/shacl#>
prefix cvkd: <http://lig-tdcge.imag.fr/steamer/covikoa/derivation#>
CONSTRUCT {
?thisIndiv a sh:NodeShape , cvkd:SymbolizerCreationRule ;
sh:targetClass ?conceptGVR ;
sh:rule [ a sh:SPARQLRule ;
sh:construct ?constructValue ;
] .
} WHERE {
?conceptGVR rdfs:subClassOf gviz:GeoVisualIntermediateRepresentation ;
cvkd:represents ?someConcept .
$this cvkd:denotesGVR ?conceptGVR ;
gviz:hasPortrayalRule ?rule .
# for now we generate one shacl rule for each TemplateSymbolizer to derive..
FILTER (EXISTS { ?rule gviz:hasSymbol/<https://gis.lu.se/ont/data_portrayal/symbolizer#hasTemplateSymbolizer> ?templateSymbolizer . })
?templateSymbolizer a <https://gis.lu.se/ont/data_portrayal/symbolizer#TemplatePointSymbolizer> .
# Possible customisable property here, the other ones in the constructed rule
OPTIONAL {
?templateSymbolizer graphic:hasGraphicSymbol/graphic:size ?symblzSize .
OPTIONAL { ?symblzSize cvkd:valueOnProperty ?symblzSizeCustomisableGraphicValue . }
OPTIONAL { ?symblzSize cvkd:formula ?symblzSizeCustomisableGraphicValueFormula . }
}
# Is there PropertyConstraint on this PortrayalRule ?
OPTIONAL {
?rule cvkd:hasPropertyConstraint ?propConstraint .
}
# Is there SpatialConstraint on this PortrayalRule ?
OPTIONAL {
?rule cvkd:hasSpatialConstraint ?spatialConstraint .
OPTIONAL {
?spatialConstraint cvkd:preludeBinding ?spatialConstraintPreBindings .
}
}
OPTIONAL {
$this cvkd:hasSPARQLFilter [
rdfs:label ?nameConditionFilter ;
rdf:value ?contentConditionFilter ;
] .
}
# Prepare the IRI for this symbolizer creation rule
BIND(
URI(
CONCAT(
"http://lig-tdcge.imag.fr/steamer/covikoa/derivation#",
replace(STR($this), STR("http://example.com/cvk-ir#"), ""),
"-PointSymbolizerCreationRule-",
STRUUID()
)
) as ?thisIndiv) .
[] a cvkd:PrefixToInject ;
rdf:value ?pfxs .
# Prepare the value for the sh:construct predicate
BIND(CONCAT(
\"\"\"
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix geo: <http://www.opengis.net/ont/geosparql#>
prefix geof: <http://www.opengis.net/def/function/geosparql/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix prov: <http://www.w3.org/ns/prov#>
prefix afn: <http://jena.apache.org/ARQ/function#>
prefix dct: <http://purl.org/dc/terms/>
prefix scale: <https://gis.lu.se/ont/visualisation_scale#>
prefix ion: <http://lig-tdcge.imag.fr/steamer/covikoa/interaction#>
prefix gviz: <http://lig-tdcge.imag.fr/steamer/covikoa/geoviz#>
prefix graphic: <https://gis.lu.se/ont/data_portrayal/graphic#>
prefix symblzr: <https://gis.lu.se/ont/data_portrayal/symbolizer#>
prefix symb: <https://gis.lu.se/ont/data_portrayal/symbol#>
prefix cvkd: <http://lig-tdcge.imag.fr/steamer/covikoa/derivation#> \n\"\"\",
str(?pfxs), \"\"\"
CONSTRUCT {
?symb a symb:Symbol .
?symb dct:title ?symbTitle .
?symb symblzr:hasSymbolizer ?symblz .
?symblz a symblzr:PointSymbolizer .
?symblz graphic:hasGraphicSymbol [
graphic:hasMark [
graphic:hasWellKnownName ?symblzNameMark ;
graphic:hasStroke [
graphic:strokeColor ?symblzStrokeColor ;
] ;
graphic:hasFill [
graphic:fillColor ?symblzFillColor ;
] ;
] ;
graphic:size ?symblzSize ;
] ;
} WHERE {
FILTER NOT EXISTS { ?symblz a symblzr:PointSymbolizer . }
BIND(<\"\"\", STR($this), \"\"\"> as ?portrayal) .
# TODO: simplify the next line ...
BIND(\"\"\", IF(isBlank(?rule), CONCAT(\"\"\"<_:\"\"\", afn:bnode(?rule), \"\"\">\"\"\"), CONCAT(\"\"\"<\"\"\", STR(?rule), \"\"\">\"\"\")), \"\"\" as ?rule) .
?portrayal cvkd:denotesGVR ?thisKind ;
gviz:hasPortrayalRule ?rule .
?rule gviz:hasSymbol/<https://gis.lu.se/ont/data_portrayal/symbolizer#hasTemplateSymbolizer> ?templateSymbolizer .
OPTIONAL { ?rule cvkd:hasPropertyConstraint ?propConstraint . }
?templateSymbolizer a symblzr:TemplatePointSymbolizer .
OPTIONAL { ?templateSymbolizer graphic:hasGraphicSymbol/graphic:hasMark/graphic:hasWellKnownName ?symblzNameMark . }
OPTIONAL { ?templateSymbolizer graphic:hasGraphicSymbol/graphic:hasMark/graphic:hasStroke/graphic:strokeColor ?symblzStrokeColor . }
OPTIONAL { ?templateSymbolizer graphic:hasGraphicSymbol/graphic:hasMark/graphic:hasFill/graphic:fillColor ?symblzFillColor . }
$this a ?thisKind ;
gviz:represents ?somethingRepresentable .
\"\"\",
IF(BOUND(?spatialConstraint), CONCAT(\"\"\" BIND(cvkd:UnPackGeomWKT(?somethingRepresentable) as ?thisGeometry)\n\"\"\", cvkd:RewriteSpatialConstraint_TODO(?spatialConstraint)), \"\"\"\"\"\"),
IF(BOUND(?contentConditionFilter), CONCAT(\"\"\"\n{\n\"\"\", STR(?contentConditionFilter), \"\"\"\n}\n\"\"\"), \"\"\"\"\"\"),
IF(BOUND(?propConstraint), cvkd:RewritePropertyConstraint(?propConstraint, ?someConcept), \"\"\"\"\"\"),
IF(!ISLITERAL(?symblzSize),
CONCAT(\"\"\" ?somethingRepresentable \"\"\", cvkd:RewriteShaclPropertyPathToSPARQLPropertyPath(?symblzSizeCustomisableGraphicValue), \"\"\" ?_symblzSize . \n BIND(STR(?_symblzSize) AS ?symbTitle) .\n\"\"\"),
CONCAT(\"\"\" BIND(\\"\"\"\", STR(?symblzSize), \"\"\"\\"^^xsd:decimal as ?_symblzSize) . \n\"\"\")),
IF(BOUND(?symblzSizeCustomisableGraphicValueFormula),
CONCAT(\"\"\" BIND((\"\"\", REPLACE(STR(?symblzSizeCustomisableGraphicValueFormula), "value", "_symblzSize"), \"\"\") as ?symblzSize) .\"\"\"),
\"\"\" BIND(?_symblzSize as ?symblzSize) .\"\"\"),
\"\"\"
BIND(IRI(CONCAT("urn:symbolizer:id:", afn:localname(?somethingRepresentable), "-", afn:localname(?templateSymbolizer))) as ?symblz) .
BIND(IRI(CONCAT("urn:symbol:id:", STRUUID())) as ?symb) .
}\"\"\"
) as ?constructValue) .
}""" ;
] .
cvkd:RuleGenerationEnrichmentRulesWithTemplateSymbolizer
a sh:NodeShape ;
rdfs:comment """Prepare the various enrichment rules for gviz:PortrayalRules that link to a TemplateSymbolizer ."""@en ;
sh:targetSubjectsOf cvkd:denotesGVR;
sh:rule [ a sh:SPARQLRule ;
sh:construct """
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix afn: <http://jena.apache.org/ARQ/function#>
prefix gviz: <http://lig-tdcge.imag.fr/steamer/covikoa/geoviz#>
prefix geo: <http://www.opengis.net/ont/geosparql#>
prefix geof: <http://www.opengis.net/def/function/geosparql/>
prefix sh: <http://www.w3.org/ns/shacl#>
prefix cvkd: <http://lig-tdcge.imag.fr/steamer/covikoa/derivation#>
CONSTRUCT {
?thisIndiv a sh:NodeShape , ?typeRule ;
sh:targetClass ?conceptGVR ;
sh:rule [ a sh:SPARQLRule ;
sh:construct ?constructValue ;
] .
} WHERE {
?conceptGVR rdfs:subClassOf gviz:GeoVisualIntermediateRepresentation ;
cvkd:represents ?someConcept .
$this cvkd:denotesGVR ?conceptGVR ;
gviz:hasPortrayalRule ?rule .
OPTIONAL {
$this cvkd:multipleGeometryType ?_multGeomType .
}
BIND(IF(Bound(?_multGeomType) && ?_multGeomType = true, true, false) as ?multipleGeomType)
# we generate one shacl rule of this type for each gviz:PortrayalRule that has template symbolizer
FILTER (EXISTS { ?rule gviz:hasSymbol/<https://gis.lu.se/ont/data_portrayal/symbolizer#hasTemplateSymbolizer> ?templateSymbolizer . })
# Is there PropertyConstraint on this PortrayalRule ?
OPTIONAL {
?rule cvkd:hasPropertyConstraint ?propConstraint .
}
# Is there SpatialConstraint on this PortrayalRule ?
OPTIONAL {
?rule cvkd:hasSpatialConstraint ?spatialConstraint .
OPTIONAL {
?spatialConstraint cvkd:preludeBinding ?spatialConstraintPreBindings .
}
}
# Is there a TransformOperation on the Portrayal or on the PortrayalRule ?
OPTIONAL {
$this cvkd:hasTransformOperation [ cvkd:preludeBinding ?preTransformOperationPortrayal ] .
}
OPTIONAL {
$this cvkd:hasTransformOperation ?transformOperationPortrayal .
}
OPTIONAL {
?rule cvkd:hasTransformOperation [ cvkd:preludeBinding ?preTransformOperationRule ] .
}
OPTIONAL {
$this cvkd:hasTransformOperation ?transformOperationRule .
}
BIND(IF(BOUND(?preTransformOperationRule), ?preTransformOperationRule, ?preTransformOperationPortrayal) as ?preTransformOperation)
BIND(IF(BOUND(?transformOperationRule), ?transformOperationRule, ?transformOperationPortrayal) as ?transformOperation)
OPTIONAL {
$this cvkd:hasSPARQLFilter [
rdfs:label ?nameConditionFilter ;
rdf:value ?contentConditionFilter ;
] .
}
OPTIONAL {
$this gviz:onComponent ?compo .
?compo a ?compoType .
FILTER(?compoType in (gviz:Map2dComponent, gviz:Map3dComponent))
}
# Prepare the type of rule between DefaultEnrichmentRule and ProblemSpecificEnrichmentRule
BIND(
IF(
BOUND(?contentConditionFilter),
cvkd:ProblemSpecificEnrichmentRule,
cvkd:DefaultEnrichmentRule
) as ?typeRule) .
# Prepare the IRI for this enrichment rule
BIND(
URI(
CONCAT(
"http://lig-tdcge.imag.fr/steamer/covikoa/derivation#",
replace(STR($this), STR("http://example.com/cvk-ir#"), ""),
"-EnrichmentRule-",
STRUUID()
)
) as ?thisIndiv) .
[] a cvkd:PrefixToInject ;
rdf:value ?pfxs .
# Prepare the value for the sh:construct predicate
BIND(CONCAT(
\"\"\"
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix geo: <http://www.opengis.net/ont/geosparql#>
prefix geof: <http://www.opengis.net/def/function/geosparql/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix prov: <http://www.w3.org/ns/prov#>
prefix scale: <https://gis.lu.se/ont/visualisation_scale#>
prefix ion: <http://lig-tdcge.imag.fr/steamer/covikoa/interaction#>
prefix gviz: <http://lig-tdcge.imag.fr/steamer/covikoa/geoviz#>
prefix afn: <http://jena.apache.org/ARQ/function#>
prefix cvkd: <http://lig-tdcge.imag.fr/steamer/covikoa/derivation#> \n\"\"\",
str(?pfxs), \"\"\"
CONSTRUCT {
$this gviz:hasMaterialisation ?materialisation .
?materialisation
geo:hasGeometry [ geo:asWKT ?resGeom ] ;
gviz:isSymbolizedBy ?symblz ;
gviz:displayIndex ?di;
prov:wasGeneratedBy <\"\"\", STR(?thisIndiv), \"\"\"> ;
prov:qualifiedGeneration ?gen ;
scale:hasScale ?scale ;
gviz:appearsIn ?component ;
cvkd:fromPortrayalRule ?rule .
?component gviz:presentsGVR $this .
} WHERE {
NOT EXISTS { $this gviz:hasMaterialisation [ prov:wasGeneratedBy <\"\"\", STR(?thisIndiv), \"\"\"> ; ] . }
BIND(<\"\"\", STR($this), \"\"\"> as ?portrayal) .
# TODO: simplify the next line ...
BIND(\"\"\", IF(isBlank(?rule), CONCAT(\"\"\"<_:\"\"\", afn:bnode(?rule), \"\"\">\"\"\"), CONCAT(\"\"\"<\"\"\", STR(?rule), \"\"\">\"\"\")), \"\"\" as ?rule) .
?portrayal cvkd:denotesGVR ?thisKind ;
gviz:hasPortrayalRule ?rule .
?rule gviz:hasSymbol/<https://gis.lu.se/ont/data_portrayal/symbolizer#hasTemplateSymbolizer> ?templateSymbolizer .
OPTIONAL { ?rule cvkd:hasPropertyConstraint ?propConstraint . }
$this a ?thisKind ;
gviz:represents ?somethingRepresentable .
\"\"\",
IF(BOUND(?contentConditionFilter), CONCAT(\"\"\"\n{\n\"\"\", STR(?contentConditionFilter), \"\"\"\n}\n\"\"\"), \"\"\"\"\"\"),
\"\"\"
BIND(cvkd:UnPackGeomWKT(?somethingRepresentable) as ?thisGeometry).\"\"\",
IF(BOUND(?spatialConstraint), cvkd:RewriteSpatialConstraint_TODO(?spatialConstraint), \"\"\"\"\"\"),
IF(BOUND(?preTransformOperation), CONCAT(\"\"\" \"\"\", ?preTransformOperation), \"\"\"\"\"\"),
IF(BOUND(?transformOperation), CONCAT(\"\"\" BIND(\"\"\", cvkd:RewriteTransformOperationAsLiteral(?transformOperation), \"\"\" as ?newGeom)\"\"\"), \"\"\"\"\"\"),
IF(BOUND(?propConstraint), cvkd:RewritePropertyConstraint(?propConstraint, ?someConcept), \"\"\"\"\"\"),
IF(?multipleGeomType = true, \"\"\"
BIND(cvkd:UnpackGeomTypeFeature(?somethingRepresentable) as ?geomType) .
FILTER ( EXISTS { ?symblz a [ <https://gis.lu.se/ont/data_portrayal/symbolizer#defaultGeometryType> ?geomType ; ]. } )\"\"\", \"\"\"\"\"\"),
\"\"\"
BIND(IRI(CONCAT("urn:symbolizer:id:", afn:localname(?somethingRepresentable), "-", afn:localname(?templateSymbolizer))) as ?symblz) .
FILTER ( EXISTS { ?symblz a <https://gis.lu.se/ont/data_portrayal/symbolizer#Symbolizer> . } )
OPTIONAL { ?portrayal gviz:displayIndex ?displayIndexPortrayal . }
OPTIONAL { ?rule gviz:displayIndex ?displayIndexRule . }
BIND(
IF(BOUND(?displayIndexRule),
?displayIndexRule,
IF(BOUND(?displayIndexPortrayal), ?displayIndexPortrayal, 500))
as ?di) .
# Fetch the scale information, might have be defined on
# each PortrayalRule or on the Portrayal using it
OPTIONAL { ?portrayal scale:hasScale ?pScale . }
OPTIONAL { ?rule scale:hasScale ?rScale . }
BIND(IF(BOUND(?rScale), ?rScale, ?pScale) as ?scale).
BIND(IF(BOUND(?newGeom), ?newGeom, ?thisGeometry) as ?resGeom) .
BIND(cvkd:GetCurrentGenerationNode() as ?gen) .\"\"\",
IF(BOUND(?compo),
CONCAT(\"\"\"\n BIND(<\"\"\", STR(?compo), \"\"\"> as ?component).\n\"\"\"),
\"\"\"\n ?app gviz:hasGeoVisualComponent ?component .\n ?component a gviz:Map2dComponent .\n\"\"\"
),
\"\"\"
BIND(IRI(CONCAT("urn:materialisation:id:", STRUUID())) as ?materialisation) .
}
\"\"\"
) as ?constructValue) .
}
""" ;
] .
cvkd:GenerateRuleForMapExtent
a sh:NodeShape ;
rdfs:comment """
Generate the rule (if needed by the Derivation Model) that will allow to compute the initial extent to geovisualise.
Note that the generated rule uses a custom SPARQL aggregate function (defined in org/me/CoViKoa/AggregateGeomFunction.java)
allowing to compute the extent of a set of geometries (it returns the WKT representation of the enveloppe).
"""@en ;
sh:targetClass gviz:GeoVisualApplication ;
sh:rule [ a sh:SPARQLRule ;
sh:construct """
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix gviz: <http://lig-tdcge.imag.fr/steamer/covikoa/geoviz#>
prefix geo: <http://www.opengis.net/ont/geosparql#>
prefix geof: <http://www.opengis.net/def/function/geosparql/>
prefix sh: <http://www.w3.org/ns/shacl#>
prefix cvkd: <http://lig-tdcge.imag.fr/steamer/covikoa/derivation#>
prefix cvkc: <http://lig-tdcge.imag.fr/steamer/covikoa/context#>
CONSTRUCT {
?uriThisRule a sh:NodeShape , cvkd:EnrichmentRule ;
sh:targetClass gviz:Map2dComponent , gviz:Map3dComponent ;
sh:rule [ a sh:SPARQLRule ;
sh:construct ?ruleContent ;
] .
} WHERE {
$this gviz:hasGeoVisualComponent ?compo .
?compo cvkd:hasDefaultExtent ?stuff .
BIND(
URI(
CONCAT(
"http://lig-tdcge.imag.fr/steamer/covikoa/derivation#map-extent-",
STRUUID()
)
) as ?uriThisRule) .
BIND(CONCAT(
\"\"\"
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix gviz: <http://lig-tdcge.imag.fr/steamer/covikoa/geoviz#>
prefix geo: <http://www.opengis.net/ont/geosparql#>
prefix geof: <http://www.opengis.net/def/function/geosparql/>
prefix sh: <http://www.w3.org/ns/shacl#>
prefix cvkd: <http://lig-tdcge.imag.fr/steamer/covikoa/derivation#>
prefix cvkc: <http://lig-tdcge.imag.fr/steamer/covikoa/context#>
prefix prov: <http://www.w3.org/ns/prov#>
prefix geoagg: <http://lig-tdcge.imag.fr/steamer/covikoa/geo-agg#>
CONSTRUCT {
$this cvkc:hasMapExtent [ a geo:Geometry ;
geo:asWKT ?geomExtent ;
prov:wasGeneratedBy <\"\"\", STR(?uriThisRule), \"\"\"> ;
prov:qualifiedGeneration ?gen ;
] .
} WHERE {
NOT EXISTS { $this cvkc:hasMapExtent [] } .
$this cvkd:hasDefaultExtent ?concept .
FILTER EXISTS { ?targetIndiv a ?concept ; geo:hasGeometry [ geo:asWKT ?geom ] . }
{
SELECT (geoagg:Extent(?geom) as ?geomExtent) {
{
$this a gviz:Map2dComponent ;
cvkd:hasDefaultExtent ?concept .
} UNION {
$this a gviz:Map3dComponent ;
cvkd:hasDefaultExtent ?concept .
}
?targetIndiv a ?concept ;
geo:hasGeometry [ geo:asWKT ?geom ] .
}
}
FILTER (DATATYPE(?geomExtent) = geo:wktLiteral)
BIND(cvkd:GetCurrentGenerationNode() as ?gen) .
}
\"\"\") as ?ruleContent) .
} """ ;
] .
cvkd:GenerateRuleLinkingDenotesConcept
a sh:NodeShape ;
rdfs:comment """
Generate the rule that will allow to link Portrayal and Symbols
to the concept from the SDM they denote
(because the user did not write it explicitly in the derivation model).
"""@en ;
sh:targetClass gviz:GeoVisualApplication ;
sh:rule [ a sh:SPARQLRule ;
sh:construct """
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix gviz: <http://lig-tdcge.imag.fr/steamer/covikoa/geoviz#>
prefix sh: <http://www.w3.org/ns/shacl#>
prefix cvkd: <http://lig-tdcge.imag.fr/steamer/covikoa/derivation#>
prefix cvkc: <http://lig-tdcge.imag.fr/steamer/covikoa/context#>
CONSTRUCT {
?uriThisRule a sh:NodeShape , cvkd:EnrichmentRule ;
sh:targetClass gviz:Portrayal ;
sh:rule [ a sh:SPARQLRule ;
sh:construct ?ruleContent ;
] .
} WHERE {
BIND(
URI(
CONCAT(
"http://lig-tdcge.imag.fr/steamer/covikoa/derivation#denotes-concept-linking",
STRUUID()
)
) as ?uriThisRule) .
BIND(CONCAT(
\"\"\"
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix sh: <http://www.w3.org/ns/shacl#>
prefix gviz: <http://lig-tdcge.imag.fr/steamer/covikoa/geoviz#>
prefix cvkd: <http://lig-tdcge.imag.fr/steamer/covikoa/derivation#>
CONSTRUCT {
$this gviz:denotesConcept ?concept .
} WHERE {
NOT EXISTS { $this gviz:denotesConcept [] } .
$this cvkd:denotesGVR ?classIR .
?classIR cvkd:represents ?concept . # We should unpack whats inside owl:unionOf if "?concept" is an union of concepts
}
\"\"\") as ?ruleContent) .
} """ ;
] .