-- Data Loading via SPASQL using "soft" pragma which invokes in-built cache-invalidation. 

SPARQL
define get:soft "soft"
select * from <http://bostonopendata-boston.opendata.arcgis.com/datasets/465e00f9632145a1ad645a27d27069b4_2.csv>
where {?s ?p ?o.};

SPARQL
define get:soft "soft"
select * from <http://bostonopendata-boston.opendata.arcgis.com/datasets/de08c6fe69c942509089e6db98c716a3_0.csv>
where {?s ?p ?o.};

SPARQL
define get:soft "soft"
select * from <http://kingsley.idehen.net/DAV/home/danielhm/Public/ca-cities-sample.csv>
where {?s ?p ?o.};



-- Test Rule Basis Latitude Relation
SPARQL

CONSTRUCT

{ ?this <#hasLatitude> ?n. }

{ GRAPH 
<http://bostonopendata-boston.opendata.arcgis.com/datasets/465e00f9632145a1ad645a27d27069b4_2.csv>
  {

	?this ?p ?n. 
FILTER (contains(str(?p),'latitude') || contains(str(?p),'Latitude') )}
}	;

-- Test Rule Basis Longitude Relation

SPARQL 

CONSTRUCT

{ ?this <#hasLongitude> ?n. }

{ GRAPH 
<http://bostonopendata-boston.opendata.arcgis.com/datasets/465e00f9632145a1ad645a27d27069b4_2.csv>
  {

	?this ?p ?n. 
FILTER (contains(str(?p),'longitude') || contains(str(?p),'Longitude') )}
}	;


-- Custom Relationship Type

SPARQL DROP SPIN LIBRARY <urn:demo:macro:geo:lib3> ;

SPARQL
CREATE SPIN LIBRARY <urn:demo:macro:geo:lib3> 
{

	CLASS <http://rdfs.org/sioc/ns#Item> {

										comment """Class instance generated from a Macro that defines Spatial Things, Longitude, and Latitude"""
							
						
										defmacro <#hasLatitude> { ?this <#hasLatitude> ?n. }

																{
																	FILTER (contains(str(?p),'latitude') || contains(str(?p),'Latitude') ) .
																	?this ?p ?n .
																	
																}	
												
										defmacro <#hasLongitude> { ?this <#hasLongitude> ?n. }
															
																{ 
																	FILTER (contains(str(?p),'longitude') || contains(str(?p),'Longitude') ) .
																	?this ?p ?n .
																	
																}																				

								 }
} 

ASK FROM virtrdf:
WHERE { ?s <nosuch> ?o};


-- Data Set #1

SPARQL 

DEFINE input:macro-lib <urn:demo:macro:geo:lib3>  


SELECT ?x ?y ?z
FROM <http://bostonopendata-boston.opendata.arcgis.com/datasets/465e00f9632145a1ad645a27d27069b4_2.csv>
WHERE { 

?x a sioc:Item .
?x <#hasLatitude> ?y.
?x <#hasLongitude> ?z.

}  ;


-- Data Set #2

SPARQL 

DEFINE input:macro-lib <urn:demo:macro:geo:lib3>  

SELECT ?y ?z
FROM <http://bostonopendata-boston.opendata.arcgis.com/datasets/465e00f9632145a1ad645a27d27069b4_2.csv>
FROM <http://bostonopendata-boston.opendata.arcgis.com/datasets/de08c6fe69c942509089e6db98c716a3_0.csv>
FROM <http://kingsley.idehen.net/DAV/home/danielhm/Public/ca-cities-sample.csv>
WHERE { 

?x a sioc:Item .

?x <#hasLatitude> ?y .
?x <#hasLongitude> ?z .

} 

