remarque: install plug-in XMLTools pour nodepad++, qui permet la validation (attention, ne placer qu'un seul xsd dans le xsj:schemaLocation).
Urls et servers¶
- geoserver : https://epos.brgm-rec.fr/geoserver/ows?service=wfs&version=2.0.0&request=GetCapabilities
- accès en SSH epos.brgm-rec.fr [voir keepass]
- les workspaces sont déportés (data_directory déporté): export GEOSERVER_DATA_DIR=/applications/projets/geoserver/data_dir/workspaces
- BD : server EPOS [voir keepass]
- spécif INSPIRE NaturalRiskZone
- http://inspire.ec.europa.eu/Themes/140/2892
- UML http://inspire.ec.europa.eu/data-model/approved/r4618-ir/html/index.htm?goto=2:3:12:1:8552
- Schema XSD : http://inspire.ec.europa.eu/schemas/nz-core/4.0/NaturalRiskZonesCore.xsd
- Et forum: https://themes.jrc.ec.europa.eu/groups/profile/1817/natural-risk-zones
- vocabs:
Install geoserver pour INSPIRE et WFS app-schema¶
- http://geoserver.org/release/stable/ (war, tomcat...) + plug-in app-schema et INSPIRE
- copier les jar des plug-in sous le WEB-INF/lib de geoserver déployé.
http://127.0.0.1:8080/geoserver/ows?request=GetCapabilities&service=wfs&version=2.0.0 - à l'install le login/pwd est admin/geoserver
mapping des données¶
On choisit (? à valider par thématicien?) de partir sur "ObservedEvent": Discrete spatial objects representing natural phenomenon relevant to the study of natural hazards which occurred, or is currently occuring, and which has been observed.- On aurait pu utiliser dans la table Pangeo la colonne "determine" qui peut être : "3_ObservedGeologyFieldCampaigns", "1_ObservedPSI", "4_PotentialInstability", "2_ObservedOtherDefMeasurement". MAIS lorsque c'est "potential" on a tout de même une date de début et de fin de l'event. donc... on reste sur de l'event observé.
- la colonne "determine" n'est donc pas utilisé (on va le mettre dans le name histoire de conserver qlq chose)
- On utilise le tag specificHazardType pour coller les valeurs (venues de la table pangeo) des hazardcategory et hazardtype. En effet, pas de correspondance entre l'ancien hazardcategory et le hazardcategory INSPIRE (http://inspire.ec.europa.eu/codeList/NaturalHazardCategoryValue).
- en hazardcategory INSPIRE on utilise (voir http://www.pangeoproject.eu/eng/what_are_geohazards pour les valeurs anciennes):
- pour les anciennes valeurs de haztype
- "1_1Earthquake" >> "earthquake"
- "1_4VolcanicInflationDeflation" >> "landslide"
- tous les "4*" qui correspondent à "4_AnthropogenicGroundInstability" >> "other geological / hydrological hazard"
- le reste >> "geological / hydrological"
- pour les anciennes valeurs de haztype
CREATE TABLE pangeo.inspireobservedevent
(
gmlid serial NOT NULL,
beginlifespanversion date, --20140101 : c'est la fin du projet.
inspireid character varying(50), -- le namespace est en dur: GBPangeoHazard
nameofevent character varying(50), -- on y met determine
hazardCategory character varying(100),
specifichazardtype character varying(200), -- on concat les anciens hazcat et haztype (les labels)
validfrom date, -- obsstart
validto date, -- obsend
geom geometry(MultiPolygon,4326),
hazcat character varying(50),
haztype character varying(50),
CONSTRAINT inspireobservedevent_pkey PRIMARY KEY (gmlid)
)
insert into pangeo.inspireobservedevent (
select gid, '2014-1-1'::date, inspireid,
(select codetranslation from pangeo.pangeovocabs where code=determine and vocab='determin'),
'', --hazardCategory
(select codetranslation from pangeo.pangeovocabs where code=hazcat and vocab='hazcat') || ': '||(select codetranslation from pangeo.pangeovocabs where code=haztype and vocab='haztype'), --specifichazardtype
obsstart, --validfrom
obsend, --validto
geom ,
hazcat, haztype
from pangeo.pangeogsl
);
update pangeo.inspireobservedevent set hazardCategory='http://inspire.ec.europa.eu/codelist/NaturalHazardCategoryValue/geologicalHydrological';
update pangeo.inspireobservedevent set hazardCategory='http://inspire.ec.europa.eu/codelist/NaturalHazardCategoryValue/otherGeologicalHydrological' where hazcat='4_AnthropogenicGroundInstability';
update pangeo.inspireobservedevent set hazardCategory='http://inspire.ec.europa.eu/codelist/NaturalHazardCategoryValue/landslide' where haztype='1_4VolcanicInflationDeflation';
update pangeo.inspireobservedevent set hazardCategory='http://inspire.ec.europa.eu/codelist/NaturalHazardCategoryValue/earthquake' where haztype='1_1Earthquake';
alter table pangeo.inspireobservedevent drop column hazcat;
alter table pangeo.inspireobservedevent drop column haztype;
GRANT SELECT ON TABLE pangeo.inspireobservedevent TO epos_reader;
Exemple de XML qui valide¶
<nz-core:ObservedEvent gml:id="PGGH_London_009"
xmlns:gml="http://www.opengis.net/gml/3.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://inspire.ec.europa.eu/schemas/nz-core/4.0/NaturalRiskZonesCore.xsd"
xmlns:nz-core="http://inspire.ec.europa.eu/schemas/nz-core/4.0"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:wfs="http://www.opengis.net/wfs/2.0"
xmlns:base="http://inspire.ec.europa.eu/schemas/base/3.3"
>
<!-- Discrete spatial objects representing natural phenomenon relevant to the study of natural hazards which occurred, or is currently occuring, and which has been observed.. -->
<nz-core:beginLifeSpanVersion xsi:nil="true"/>
<!-- Date and time at which this version of the spatial object was inserted or changed in the spatial data set.-->
<nz-core:endLifeSpanVersion xsi:nil="true"/><!-- no value in our database -->
<nz-core:inspireId>
<base:Identifier >
<base:localId>PGGH_London_009</base:localId>
<base:namespace>GBPangeoHazard</base:namespace>
</base:Identifier>
</nz-core:inspireId>
<nz-core:nameOfEvent>XXX</nz-core:nameOfEvent>
<nz-core:typeOfHazard>
<!-- A generic classification and a specific classification of the type of natural hazard. -->
<nz-core:NaturalHazardClassification>
<nz-core:hazardCategory xlink:href="4_AnthropogenicGroundInstability"/> <!-- http://inspire.ec.europa.eu/codeList/NaturalHazardCategoryValue -->
<nz-core:specificHazardType xlink:title="4_5UndergroundConstruction"/> <!--
Additional classification of the natural hazard that further specifies the hazard
type according to a nomenclature that is specific to this dataset. -->
</nz-core:NaturalHazardClassification>
</nz-core:typeOfHazard>
<nz-core:validFrom>1992-06-19T00:00:00</nz-core:validFrom><!-- The time when the observed event started to exist in the real world.-->
<nz-core:validTo>2010-09-17T00:00:00</nz-core:validTo>
<nz-core:geometry></nz-core:geometry>
<nz-core:magnitudeOrIntensity xsi:nil="true"/>
<!-- An expression of the magnitude or the intensity of a phenomenon.
It may address a value within the Richter scale, or a description of the european macro-seismic scale, or a flood flow, etc... -->
</nz-core:ObservedEvent>
Configuration geoserver pour WFS app-schema¶
Voir aussi: https://forge.brgm.fr/projects/standardisation/wiki/REX_implementations_BRGM
Voir aussi: http://www.onegeology.org/docs/technical/OneGeologyWFSCookbook_v1.0.pdf
Voir aussi: http://docs.geoserver.org/stable/en/user/data/app-schema/index.html
Recharger par la console d'admin GEOSERVER quand modif des fichiers XML (il suffit de sauver la configuration globale).
Par l'interface admin geoserver:
- création espace de travail "nz-core" avec uri http://inspire.ec.europa.eu/schemas/nz-core/4.0
- Cela créé le répertoire nz-core dans les Namespace.
- création des espaces de travail pour les autres namespace (juste le namespace et uri): base, gml, xlink.
- aller déposer (par copie d'un exemple existant) workspaces/nz-core/nz-core_ObservedEvent/nz-core_ObservedEvent_mapping.xml
- l'éditer correctement (...)
- les variables sont définies ailleurs: http://docs.geoserver.org/stable/en/user/data/app-schema/property-interpolation.html#app-schema-property-interpolation
- peuvent être mises en dur sinon.
- le bon url de .xsd: http://inspire.ec.europa.eu/schemas/nz-core/4.0/NaturalRiskZonesCore.xsd
- et le mapping (sourceType est le nom de table) http://docs.geoserver.org/stable/en/user/data/app-schema/mapping-file.html#mappings
<?xml version="1.0" encoding="UTF-8"?> <as:AppSchemaDataAccess xmlns:as="http://www.geotools.org/app-schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.geotools.org/app-schema AppSchemaDataAccess.xsd"> <namespaces> <Namespace> <prefix>gml</prefix> <uri>http://www.opengis.net/gml/3.2</uri> </Namespace> <Namespace> <prefix>gsmlp</prefix> <uri>https://forge.brgm.fr/svnrepository/epos/trunk/schemas</uri> </Namespace> <Namespace> <prefix>nz-core</prefix> <uri>http://inspire.ec.europa.eu/schemas/nz-core/4.0</uri> </Namespace> <Namespace> <prefix>xlink</prefix> <uri>http://www.w3.org/1999/xlink</uri> </Namespace> <Namespace> <prefix>xsi</prefix> <uri>http://www.w3.org/2001/XMLSchema-instance</uri> </Namespace> <Namespace> <prefix>wfs</prefix> <uri>http://www.opengis.net/wfs/2.0</uri> </Namespace> <Namespace> <prefix>base</prefix> <uri>http://inspire.ec.europa.eu/schemas/base/3.3</uri> </Namespace> </namespaces> <sourceDataStores> <DataStore> <id>datastore</id> <parameters> <Parameter> <name>dbtype</name> <value>postgisng</value> </Parameter> <Parameter> <name>host</name> <value>192.168.16.66</value> </Parameter> <Parameter> <name>port</name> <value>5432</value> </Parameter> <Parameter> <name>database</name> <value>epos</value> </Parameter> <Parameter> <name>user</name> <value>epos_user</value> </Parameter> <Parameter> <name>passwd</name> <value>borehole</value> </Parameter> <Parameter> <name>schema</name> <value>pangeo</value> </Parameter> <Parameter> <name>Expose primary keys</name> <value>true</value> </Parameter> </parameters> </DataStore> </sourceDataStores> <!--<catalog>../../../schemas/catalog.xml</catalog>--> <targetTypes> <FeatureType> <schemaUri>http://inspire.ec.europa.eu/schemas/nz-core/4.0/NaturalRiskZonesCore.xsd</schemaUri> </FeatureType> </targetTypes> <typeMappings> <FeatureTypeMapping> <isDenormalised>false</isDenormalised> <sourceDataStore>datastore</sourceDataStore> <sourceType>inspireobservedevent</sourceType> <targetElement>nz-core:ObservedEvent</targetElement> <attributeMappings> <AttributeMapping> <targetAttribute>nz-core:ObservedEvent</targetAttribute> <idExpression> <OCQL>gmlid</OCQL> </idExpression> </AttributeMapping> <AttributeMapping> <targetAttribute>nz-core:beginLifeSpanVersion</targetAttribute> <sourceExpression> <OCQL>beginlifespanversion</OCQL> </sourceExpression> </AttributeMapping> <AttributeMapping> <targetAttribute>nz-core:inspireId/base:Identifier/base:localId</targetAttribute> <sourceExpression> <OCQL>inspireid</OCQL> </sourceExpression> </AttributeMapping> <AttributeMapping> <targetAttribute>nz-core:inspireId/base:Identifier/base:namespace</targetAttribute> <sourceExpression> <OCQL>'PangeoHazard'</OCQL> </sourceExpression> </AttributeMapping> <AttributeMapping> <targetAttribute>nz-core:nameOfEvent</targetAttribute> <sourceExpression> <OCQL>nameofevent</OCQL> </sourceExpression> </AttributeMapping> <AttributeMapping> <targetAttribute>nz-core:typeOfHazard/nz-core:NaturalHazardClassification/nz-core:hazardCategory</targetAttribute> <ClientProperty> <name>xlink:href</name> <value>hazardcategory</value> </ClientProperty> </AttributeMapping> <AttributeMapping> <targetAttribute>nz-core:typeOfHazard/nz-core:NaturalHazardClassification/nz-core:specificHazardType</targetAttribute> <ClientProperty> <name>xlink:title</name> <value>specifichazardtype</value> </ClientProperty> </AttributeMapping> <!-- mettre nill si null dans la BD : je ne sais pas faire... --> <AttributeMapping> <targetAttribute>nz-core:validFrom</targetAttribute> <sourceExpression> <OCQL>validfrom</OCQL> </sourceExpression> </AttributeMapping> <AttributeMapping> <targetAttribute>nz-core:validTo</targetAttribute> <sourceExpression> <OCQL>validto</OCQL> </sourceExpression> </AttributeMapping> <AttributeMapping> <targetAttribute>nz-core:geometry</targetAttribute> <sourceExpression> <OCQL>geom</OCQL> </sourceExpression> </AttributeMapping> <!-- <nz-core:magnitudeOrIntensity xsi:nil="true"/> --> <AttributeMapping> <targetAttribute>nz-core:magnitudeOrIntensity</targetAttribute> <ClientProperty> <name>xsi:nil</name> <value>'true'</value> </ClientProperty> </AttributeMapping> </attributeMappings> </FeatureTypeMapping> </typeMappings> </as:AppSchemaDataAccess>
- l'éditer correctement (...)
- création datastore (entrepot) "datascoreAppschema-nz-core" de type "Application Schema DataAccess" ,
- avec file:workspaces/nz-core/datascoreAppschema-nz-core/nz-core_ObservedEvent_datasource.xml (qu'il faut créer auparavant, par copie par exemple d'un fichier existant)
- pour continuer à travailler sur le mapping, pour prise en compte il suffit de réacceder à la définition de ce datastore et sauver.
- Désormais la couche existe (aller voir dans la liste des couches): la publier (ajouter l'emprise).
- on constate la création d'un folder "ObservedEvent" (du nom du typeName)