--Clear Named Graphs

-- SPARQL  clear graph <http://bostonopendata-boston.opendata.arcgis.com/datasets/465e00f9632145a1ad645a27d27069b4_2.csv>;

-- SPARQL clear graph <http://bostonopendata-boston.opendata.arcgis.com/datasets/de08c6fe69c942509089e6db98c716a3_0.csv>;

-- Data Definition via SPASQL

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.};


-- Data Consolidation via SPASQL

SPARQL clear graph <urn:demo:macro:geo>;

SPARQL
Insert 
{graph <urn:demo:macro:custom:infererence:rule:geo> {?s ?p ?o}}
where {
select * from <http://bostonopendata-boston.opendata.arcgis.com/datasets/465e00f9632145a1ad645a27d27069b4_2.csv> where {?s ?p ?o.}
};

SPARQL
Insert 
{graph <urn:demo:macro:custom:infererence:rule:geo> {?s ?p ?o}}

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


-- Custom Relationship Type

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

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

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

						comment """Class instance generated from a Macro that defines schema:brand"""
						
						defmacro <hasLatitude> { ?this <http://www.w3.org/2003/01/geo/wgs84_pos#lat> ?n. }
												{{
													?this <http://bostonopendata-boston.opendata.arcgis.com/datasets/465e00f9632145a1ad645a27d27069b4_2.csv#Latitude> ?n.

												}}
												
						defmacro <hasLongitude> { ?this <http://www.w3.org/2003/01/geo/wgs84_pos#long> ?n. }
												{{
													?this <http://bostonopendata-boston.opendata.arcgis.com/datasets/465e00f9632145a1ad645a27d27069b4_2.csv#Longitude> ?n.

												}}						
																								

}
}


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


-- Sample query

SPARQL 

DEFINE input:macro-lib <urn:demo:macro:geo:lib>  
PREFIX  rel:  <http://purl.org/vocab/relationship/> 

WITH <urn:demo:macro:geo>
SELECT ?x ?y ?z

WHERE { 

?x a <http://bostonopendata-boston.opendata.arcgis.com/datasets/465e00f9632145a1ad645a27d27069b4_2.csv#class>.

?x geo:long ?y.

?x geo:lat ?z.

} 

limit 10
;