[GRASS-SVN] r60812 - in sandbox/krejcmat: . src src/data

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jun 12 15:26:32 PDT 2014


Author: krejcmat
Date: 2014-06-12 15:26:32 -0700 (Thu, 12 Jun 2014)
New Revision: 60812

Added:
   sandbox/krejcmat/src/
   sandbox/krejcmat/src/data/
   sandbox/krejcmat/src/data/grassBasicISOTemplate.xml
   sandbox/krejcmat/src/data/grassInspireTemplate.xml
   sandbox/krejcmat/src/mdgrass.py
   sandbox/krejcmat/src/r.info.iso.py
   sandbox/krejcmat/src/v.info.iso.py
Log:
sources of basic modules 

Added: sandbox/krejcmat/src/data/grassBasicISOTemplate.xml
===================================================================
--- sandbox/krejcmat/src/data/grassBasicISOTemplate.xml	                        (rev 0)
+++ sandbox/krejcmat/src/data/grassBasicISOTemplate.xml	2014-06-12 22:26:32 UTC (rev 60812)
@@ -0,0 +1,236 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ISO 19115:2003 file created from OWSLib object model -->
+<gmd:MD_Metadata xsi:schemaLocation="http://www.isotc211.org/2005/gmd http://schemas.opengis.net/iso/19139/20060504/gmd/gmd.xsd" xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" xmlns:xlink="http://www.w3.org/1999/xlink">
+  <gmd:fileIdentifier>
+    <gco:CharacterString>{{ md.identifier }}</gco:CharacterString>
+  </gmd:fileIdentifier>
+  <gmd:language>
+    <gmd:LanguageCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#LanguageCode" codeListValue="eng">{{ md.languagecode }}</gmd:LanguageCode>
+  </gmd:language>
+  <gmd:hierarchyLevel>
+    <gmd:MD_ScopeCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_ScopeCode" codeListValue="dataset" codeSpace="ISOTC211/19115">{{ md.identification.identtype }}</gmd:MD_ScopeCode>
+  </gmd:hierarchyLevel>
+  {% for co in md.contact -%}
+  <gmd:contact>
+    <gmd:CI_ResponsibleParty>
+      <gmd:organisationName>
+        <gco:CharacterString>{{ co.organization }}</gco:CharacterString>
+      </gmd:organisationName>
+      <gmd:contactInfo>
+        <gmd:CI_Contact>
+          <gmd:address>
+            <gmd:CI_Address>
+              <gmd:electronicMailAddress>
+                <gco:CharacterString>{{ co.email }}</gco:CharacterString>
+              </gmd:electronicMailAddress>
+            </gmd:CI_Address>
+          </gmd:address>
+        </gmd:CI_Contact>
+      </gmd:contactInfo>
+      <gmd:role>
+        <gmd:CI_RoleCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_RoleCode" codeListValue={{ "\"%s\"" % co.role }} codeSpace="ISOTC211/19115">{{ co.role }}</gmd:CI_RoleCode>
+      </gmd:role>
+    </gmd:CI_ResponsibleParty>
+  </gmd:contact>
+  {% endfor -%}
+  <gmd:dateStamp>
+    <gco:Date>{{ md.datestamp }}</gco:Date>
+  </gmd:dateStamp>
+  <gmd:metadataStandardName>
+    <gco:CharacterString>ISO 19115</gco:CharacterString>
+  </gmd:metadataStandardName>
+  <gmd:metadataStandardVersion>
+    <gco:CharacterString>2003/Cor.1:2006</gco:CharacterString>
+  </gmd:metadataStandardVersion>
+  <gmd:identificationInfo>
+    <gmd:MD_DataIdentification>
+      <gmd:citation>
+        <gmd:CI_Citation>
+          <gmd:title>
+            <gco:CharacterString>{{ md.identification.title }}</gco:CharacterString>
+          </gmd:title>
+          {% for d in md.identification.date -%}
+          <gmd:date>
+            <gmd:CI_Date>
+              <gmd:date>
+                <gco:DateTime>{{ d.date }}</gco:DateTime>
+              </gmd:date>
+              <gmd:dateType>
+                <gmd:CI_DateTypeCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_DateTypeCode" codeListValue={{ "\"%s\"" % d.type }} codeSpace="ISOTC211/19115">{{ d.type }}</gmd:CI_DateTypeCode>
+              </gmd:dateType>
+            </gmd:CI_Date>
+          </gmd:date>
+          {% endfor -%}
+          <gmd:identifier>
+            <gmd:RS_Identifier>
+              <gmd:code>
+                <gco:CharacterString>{{ md.identifier }}</gco:CharacterString>
+              </gmd:code>
+            </gmd:RS_Identifier>
+          </gmd:identifier>
+        </gmd:CI_Citation>
+      </gmd:citation>
+      <gmd:abstract>
+        <gco:CharacterString>{{ md.identification.abstract }}</gco:CharacterString>
+      </gmd:abstract>
+      {% for co in md.identification.contact -%}
+      <gmd:pointOfContact>
+        <gmd:CI_ResponsibleParty>
+          <gmd:organisationName>
+            <gco:CharacterString>{{ co.organization }}</gco:CharacterString>
+          </gmd:organisationName>
+          <gmd:contactInfo>
+            <gmd:CI_Contact>
+              <gmd:address>
+                <gmd:CI_Address>
+                  <gmd:electronicMailAddress>
+                    <gco:CharacterString>{{ co.email }}</gco:CharacterString>
+                  </gmd:electronicMailAddress>
+                </gmd:CI_Address>
+              </gmd:address>
+            </gmd:CI_Contact>
+          </gmd:contactInfo>
+          <gmd:role>
+            <gmd:CI_RoleCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_RoleCode" codeListValue={{ "\"%s\"" % co.role }} codeSpace="ISOTC211/19115">{{ co.role }}</gmd:CI_RoleCode>
+          </gmd:role>
+        </gmd:CI_ResponsibleParty>
+      </gmd:pointOfContact>
+      {% endfor -%}
+      {% if md.identification.denominators|length > 0 -%}
+      {% for den in md.identification.denominators -%}
+      <gmd:spatialResolution>
+        <gmd:MD_Resolution>
+          <gmd:equivalentScale>
+            <gmd:MD_RepresentativeFraction>
+              <gmd:denominator>
+                <gco:Integer>{{ den }}</gco:Integer>
+              </gmd:denominator>
+            </gmd:MD_RepresentativeFraction>
+          </gmd:equivalentScale>
+        </gmd:MD_Resolution>
+      </gmd:spatialResolution>
+      {% endfor -%}
+      {% endif -%}
+      {% if md.identification.distance|length > 0 and md.identification.uom|length > 0 -%}
+      {% for (d,u) in zip(md.identification.distance, md.identification.uom) -%}
+      <gmd:spatialResolution>
+        <gmd:MD_Resolution>
+          <gmd:distance>
+            <gco:Distance uom={{ "\"%s\"" % u }}>{{ d }}</gco:Distance>
+          </gmd:distance>
+        </gmd:MD_Resolution>
+      </gmd:spatialResolution>
+      {% endfor -%}
+      {% endif -%}
+      {% for lan in md.identification.resourcelanguage -%}
+      <gmd:language>
+        <gmd:LanguageCode codeList="http://www.isotc211.org/2005/resources/Codelist/ML_gmxCodelists.xml#LanguageCode" codeListValue={{ "\"%s\"" % lan }}>{{ lan }}</gmd:LanguageCode>
+      </gmd:language>
+      {% endfor -%}
+      <gmd:extent>
+        <gmd:EX_Extent>
+          <gmd:geographicElement>
+            <gmd:EX_GeographicBoundingBox>
+              <gmd:westBoundLongitude>
+                <gco:Decimal>{{ md.identification.extent.boundingBox.minx }}</gco:Decimal>
+              </gmd:westBoundLongitude>
+              <gmd:eastBoundLongitude>
+                <gco:Decimal>{{ md.identification.extent.boundingBox.maxx }}</gco:Decimal>
+              </gmd:eastBoundLongitude>
+              <gmd:southBoundLatitude>
+                <gco:Decimal>{{ md.identification.extent.boundingBox.miny }}</gco:Decimal>
+              </gmd:southBoundLatitude>
+              <gmd:northBoundLatitude>
+                <gco:Decimal>{{ md.identification.extent.boundingBox.maxy }}</gco:Decimal>
+              </gmd:northBoundLatitude>
+            </gmd:EX_GeographicBoundingBox>
+          </gmd:geographicElement>
+        </gmd:EX_Extent>
+      </gmd:extent>
+    </gmd:MD_DataIdentification>
+  </gmd:identificationInfo>
+  <gmd:distributionInfo>
+    <gmd:MD_Distribution>
+      <gmd:distributionFormat>
+        <gmd:MD_Format>
+          <gmd:name gco:nilReason="inapplicable"/>
+          <gmd:version gco:nilReason="inapplicable"/>
+        </gmd:MD_Format>
+      </gmd:distributionFormat>
+      <gmd:transferOptions>
+        <gmd:MD_DigitalTransferOptions>
+          {% for ln in md.distribution.online -%}
+          <gmd:onLine>
+            <gmd:CI_OnlineResource>
+              <gmd:linkage>
+                <gmd:URL>{{ ln.url }}</gmd:URL>
+              </gmd:linkage>
+            </gmd:CI_OnlineResource>
+          </gmd:onLine>
+          {% endfor -%}
+        </gmd:MD_DigitalTransferOptions>
+      </gmd:transferOptions>
+    </gmd:MD_Distribution>
+  </gmd:distributionInfo>
+  <gmd:dataQualityInfo>
+    <gmd:DQ_DataQuality>
+      <gmd:scope>
+        <gmd:DQ_Scope>
+          <gmd:level>
+            <gmd:MD_ScopeCode codeListValue={{ "\"%s\"" % md.identification.identtype }} codeList="http://www.isotc211.org/2005/resources/Codelist/ML_gmxCodelists.xml#MD_ScopeCode">{{ md.identification.identtype }}</gmd:MD_ScopeCode>
+          </gmd:level>
+        </gmd:DQ_Scope>
+      </gmd:scope>
+      {% for (t,d,dt,dg) in zip(md.dataquality.conformancetitle,md.dataquality.conformancedate,md.dataquality.conformancedatetype,md.dataquality.conformancedegree) -%}
+      <gmd:report>
+        <gmd:DQ_DomainConsistency xsi:type="gmd:DQ_DomainConsistency_Type">
+          <gmd:measureIdentification>
+            <gmd:RS_Identifier>
+              <gmd:code>
+                <gco:CharacterString>Conformity</gco:CharacterString>
+              </gmd:code>
+              <gmd:codeSpace>
+                <gco:CharacterString>INSPIRE</gco:CharacterString>
+              </gmd:codeSpace>
+            </gmd:RS_Identifier>
+          </gmd:measureIdentification>
+          <gmd:result>
+            <gmd:DQ_ConformanceResult xsi:type="gmd:DQ_ConformanceResult_Type">
+              <gmd:specification>
+                <gmd:CI_Citation>
+                  <gmd:title>
+                    <gco:CharacterString>{{ t }}</gco:CharacterString>
+                  </gmd:title>
+                  <gmd:date>
+                    <gmd:CI_Date>
+                      <gmd:date>
+                        <gco:Date>{{ d }}</gco:Date>
+                      </gmd:date>
+                      <gmd:dateType>
+                        <gmd:CI_DateTypeCode codeList="http://www.isotc211.org/2005/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue={{ "\"%s\"" % dt }}>{{ dt }}</gmd:CI_DateTypeCode>
+                      </gmd:dateType>
+                    </gmd:CI_Date>
+                  </gmd:date>
+                </gmd:CI_Citation>
+              </gmd:specification>
+              <gmd:explanation>
+                <gco:CharacterString>See the referenced specification</gco:CharacterString>
+              </gmd:explanation>
+              <gmd:pass>
+                <gco:Boolean>{{ dg }}</gco:Boolean>
+              </gmd:pass>
+            </gmd:DQ_ConformanceResult>
+          </gmd:result>
+        </gmd:DQ_DomainConsistency>
+      </gmd:report>
+      {% endfor -%}
+      <gmd:lineage>
+        <gmd:LI_Lineage>
+          <gmd:statement>
+            <gco:CharacterString>{{ md.dataquality.lineage }}</gco:CharacterString>
+          </gmd:statement>
+        </gmd:LI_Lineage>
+      </gmd:lineage>
+    </gmd:DQ_DataQuality>
+  </gmd:dataQualityInfo>
+</gmd:MD_Metadata>

Added: sandbox/krejcmat/src/data/grassInspireTemplate.xml
===================================================================
--- sandbox/krejcmat/src/data/grassInspireTemplate.xml	                        (rev 0)
+++ sandbox/krejcmat/src/data/grassInspireTemplate.xml	2014-06-12 22:26:32 UTC (rev 60812)
@@ -0,0 +1,306 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ISO 19115:2003 file created from OWSLib object model -->
+<gmd:MD_Metadata xsi:schemaLocation="http://www.isotc211.org/2005/gmd http://schemas.opengis.net/iso/19139/20060504/gmd/gmd.xsd" xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" xmlns:xlink="http://www.w3.org/1999/xlink">
+  <gmd:fileIdentifier>
+    <gco:CharacterString>{{ md.identifier }}</gco:CharacterString>
+  </gmd:fileIdentifier>
+  <gmd:language>
+    <gmd:LanguageCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#LanguageCode" codeListValue="eng">{{ md.languagecode }}</gmd:LanguageCode>
+  </gmd:language>
+  <gmd:hierarchyLevel>
+    <gmd:MD_ScopeCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_ScopeCode" codeListValue="dataset" codeSpace="ISOTC211/19115">{{ md.identification.identtype }}</gmd:MD_ScopeCode>
+  </gmd:hierarchyLevel>
+  {% for co in md.contact -%}
+  <gmd:contact>
+    <gmd:CI_ResponsibleParty>
+      <gmd:organisationName>
+        <gco:CharacterString>{{ co.organization }}</gco:CharacterString>
+      </gmd:organisationName>
+      <gmd:contactInfo>
+        <gmd:CI_Contact>
+          <gmd:address>
+            <gmd:CI_Address>
+              <gmd:electronicMailAddress>
+                <gco:CharacterString>{{ co.email }}</gco:CharacterString>
+              </gmd:electronicMailAddress>
+            </gmd:CI_Address>
+          </gmd:address>
+        </gmd:CI_Contact>
+      </gmd:contactInfo>
+      <gmd:role>
+        <gmd:CI_RoleCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_RoleCode" codeListValue={{ "\"%s\"" % co.role }} codeSpace="ISOTC211/19115">{{ co.role }}</gmd:CI_RoleCode>
+      </gmd:role>
+    </gmd:CI_ResponsibleParty>
+  </gmd:contact>
+  {% endfor -%}
+  <gmd:dateStamp>
+    <gco:Date>{{ md.datestamp }}</gco:Date>
+  </gmd:dateStamp>
+  <gmd:metadataStandardName>
+    <gco:CharacterString>ISO 19115</gco:CharacterString>
+  </gmd:metadataStandardName>
+  <gmd:metadataStandardVersion>
+    <gco:CharacterString>2003/Cor.1:2006</gco:CharacterString>
+  </gmd:metadataStandardVersion>
+  <gmd:identificationInfo>
+    <gmd:MD_DataIdentification>
+      <gmd:citation>
+        <gmd:CI_Citation>
+          <gmd:title>
+            <gco:CharacterString>{{ md.identification.title }}</gco:CharacterString>
+          </gmd:title>
+          {% for d in md.identification.date -%}
+          <gmd:date>
+            <gmd:CI_Date>
+              <gmd:date>
+                <gco:DateTime>{{ d.date }}</gco:DateTime>
+              </gmd:date>
+              <gmd:dateType>
+                <gmd:CI_DateTypeCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_DateTypeCode" codeListValue={{ "\"%s\"" % d.type }} codeSpace="ISOTC211/19115">{{ d.type }}</gmd:CI_DateTypeCode>
+              </gmd:dateType>
+            </gmd:CI_Date>
+          </gmd:date>
+          {% endfor -%}
+          <gmd:identifier>
+            <gmd:RS_Identifier>
+              <gmd:code>
+                <gco:CharacterString>{{ md.identifier }}</gco:CharacterString>
+              </gmd:code>
+            </gmd:RS_Identifier>
+          </gmd:identifier>
+        </gmd:CI_Citation>
+      </gmd:citation>
+      <gmd:abstract>
+        <gco:CharacterString>{{ md.identification.abstract }}</gco:CharacterString>
+      </gmd:abstract>
+      {% for co in md.identification.contact -%}
+      <gmd:pointOfContact>
+        <gmd:CI_ResponsibleParty>
+          <gmd:organisationName>
+            <gco:CharacterString>{{ co.organization }}</gco:CharacterString>
+          </gmd:organisationName>
+          <gmd:contactInfo>
+            <gmd:CI_Contact>
+              <gmd:address>
+                <gmd:CI_Address>
+                  <gmd:electronicMailAddress>
+                    <gco:CharacterString>{{ co.email }}</gco:CharacterString>
+                  </gmd:electronicMailAddress>
+                </gmd:CI_Address>
+              </gmd:address>
+            </gmd:CI_Contact>
+          </gmd:contactInfo>
+          <gmd:role>
+            <gmd:CI_RoleCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_RoleCode" codeListValue={{ "\"%s\"" % co.role }} codeSpace="ISOTC211/19115">{{ co.role }}</gmd:CI_RoleCode>
+          </gmd:role>
+        </gmd:CI_ResponsibleParty>
+      </gmd:pointOfContact>
+      {% endfor -%}
+      {% for k in md.identification.keywords -%}
+      <gmd:descriptiveKeywords>
+        <gmd:MD_Keywords>
+          {% for kw in k['keywords'] -%}
+          <gmd:keyword>
+            <gco:CharacterString>{{ kw }}</gco:CharacterString>
+          </gmd:keyword>
+          {% endfor -%}
+          <gmd:thesaurusName>
+            <gmd:CI_Citation>
+              <gmd:title>
+                <gco:CharacterString>{{ k['thesaurus']['title'] }}</gco:CharacterString>
+              </gmd:title>
+              <gmd:date>
+                <gmd:CI_Date>
+                  <gmd:date>
+                    <gco:Date>{{ k['thesaurus']['date'] }}</gco:Date>
+                  </gmd:date>
+                  <gmd:dateType>
+                    <gmd:CI_DateTypeCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_DateTypeCode" codeListValue={{ "\"%s\"" % k['thesaurus']['datetype'] }}>{{ k['thesaurus']['datetype'] }}</gmd:CI_DateTypeCode>
+                  </gmd:dateType>
+                </gmd:CI_Date>
+              </gmd:date>
+            </gmd:CI_Citation>
+          </gmd:thesaurusName>
+        </gmd:MD_Keywords>
+      </gmd:descriptiveKeywords>
+      {% endfor -%}
+      {% for rc in md.identification.uselimitation -%}
+      <gmd:resourceConstraints>
+        <gmd:MD_Constraints>
+          <gmd:useLimitation>
+            <gco:CharacterString>{{ rc }}</gco:CharacterString>
+          </gmd:useLimitation>
+        </gmd:MD_Constraints>
+      </gmd:resourceConstraints>
+      {% endfor -%}
+      {% for oc in md.identification.otherconstraints -%}
+      <gmd:resourceConstraints>
+        <gmd:MD_LegalConstraints>
+          <gmd:accessConstraints>
+            <gmd:MD_RestrictionCode codeList="http://www.isotc211.org/2005/resources/Codelist/ML_gmxCodelists.xml#MD_RestrictionCode" codeListValue="otherRestrictions">otherRestrictions</gmd:MD_RestrictionCode>
+          </gmd:accessConstraints>
+          <gmd:otherConstraints>
+            <gco:CharacterString>{{ oc }}</gco:CharacterString>
+          </gmd:otherConstraints>
+        </gmd:MD_LegalConstraints>
+      </gmd:resourceConstraints>
+      {% endfor -%}
+      {% if md.identification.denominators|length > 0 -%}
+      {% for den in md.identification.denominators -%}
+      <gmd:spatialResolution>
+        <gmd:MD_Resolution>
+          <gmd:equivalentScale>
+            <gmd:MD_RepresentativeFraction>
+              <gmd:denominator>
+                <gco:Integer>{{ den }}</gco:Integer>
+              </gmd:denominator>
+            </gmd:MD_RepresentativeFraction>
+          </gmd:equivalentScale>
+        </gmd:MD_Resolution>
+      </gmd:spatialResolution>
+      {% endfor -%}
+      {% endif -%}
+      {% if md.identification.distance|length > 0 and md.identification.uom|length > 0 -%}
+      {% for (d,u) in zip(md.identification.distance, md.identification.uom) -%}
+      <gmd:spatialResolution>
+        <gmd:MD_Resolution>
+          <gmd:distance>
+            <gco:Distance uom={{ "\"%s\"" % u }}>{{ d }}</gco:Distance>
+          </gmd:distance>
+        </gmd:MD_Resolution>
+      </gmd:spatialResolution>
+      {% endfor -%}
+      {% endif -%}
+      {% for lan in md.identification.resourcelanguage -%}
+      <gmd:language>
+        <gmd:LanguageCode codeList="http://www.isotc211.org/2005/resources/Codelist/ML_gmxCodelists.xml#LanguageCode" codeListValue={{ "\"%s\"" % lan }}>{{ lan }}</gmd:LanguageCode>
+      </gmd:language>
+      {% endfor -%}
+      {% for tc in md.identification.topiccategory -%}
+      <gmd:topicCategory>
+        <gmd:MD_TopicCategoryCode>{{ tc }}</gmd:MD_TopicCategoryCode>
+      </gmd:topicCategory>
+      {% endfor -%}
+      <gmd:extent>
+        <gmd:EX_Extent>
+          <gmd:geographicElement>
+            <gmd:EX_GeographicBoundingBox>
+              <gmd:westBoundLongitude>
+                <gco:Decimal>{{ md.identification.extent.boundingBox.minx }}</gco:Decimal>
+              </gmd:westBoundLongitude>
+              <gmd:eastBoundLongitude>
+                <gco:Decimal>{{ md.identification.extent.boundingBox.maxx }}</gco:Decimal>
+              </gmd:eastBoundLongitude>
+              <gmd:southBoundLatitude>
+                <gco:Decimal>{{ md.identification.extent.boundingBox.miny }}</gco:Decimal>
+              </gmd:southBoundLatitude>
+              <gmd:northBoundLatitude>
+                <gco:Decimal>{{ md.identification.extent.boundingBox.maxy }}</gco:Decimal>
+              </gmd:northBoundLatitude>
+            </gmd:EX_GeographicBoundingBox>
+          </gmd:geographicElement>
+        </gmd:EX_Extent>
+      </gmd:extent>
+      {% if md.identification.temporalextent_start != None -%}
+      <gmd:extent>
+        <gmd:EX_Extent>
+          <gmd:temporalElement>
+            <gmd:EX_TemporalExtent>
+              <gmd:extent>
+                <gml:TimePeriod xsi:type="gml:TimePeriodType">
+                  <gml:beginPosition>{{ md.identification.temporalextent_start }}</gml:beginPosition>
+                  <gml:endPosition>{{ md.identification.temporalextent_end }}</gml:endPosition>
+                </gml:TimePeriod>
+              </gmd:extent>
+            </gmd:EX_TemporalExtent>
+          </gmd:temporalElement>
+        </gmd:EX_Extent>
+      </gmd:extent>
+      {% endif -%}
+    </gmd:MD_DataIdentification>
+  </gmd:identificationInfo>
+  <gmd:distributionInfo>
+    <gmd:MD_Distribution>
+      <gmd:distributionFormat>
+        <gmd:MD_Format>
+          <gmd:name gco:nilReason="inapplicable"/>
+          <gmd:version gco:nilReason="inapplicable"/>
+        </gmd:MD_Format>
+      </gmd:distributionFormat>
+      <gmd:transferOptions>
+        <gmd:MD_DigitalTransferOptions>
+          {% for ln in md.distribution.online -%}
+          <gmd:onLine>
+            <gmd:CI_OnlineResource>
+              <gmd:linkage>
+                <gmd:URL>{{ ln.url }}</gmd:URL>
+              </gmd:linkage>
+            </gmd:CI_OnlineResource>
+          </gmd:onLine>
+          {% endfor -%}
+        </gmd:MD_DigitalTransferOptions>
+      </gmd:transferOptions>
+    </gmd:MD_Distribution>
+  </gmd:distributionInfo>
+  <gmd:dataQualityInfo>
+    <gmd:DQ_DataQuality>
+      <gmd:scope>
+        <gmd:DQ_Scope>
+          <gmd:level>
+            <gmd:MD_ScopeCode codeListValue={{ "\"%s\"" % md.identification.identtype }} codeList="http://www.isotc211.org/2005/resources/Codelist/ML_gmxCodelists.xml#MD_ScopeCode">{{ md.identification.identtype }}</gmd:MD_ScopeCode>
+          </gmd:level>
+        </gmd:DQ_Scope>
+      </gmd:scope>
+      {% for (t,d,dt,dg) in zip(md.dataquality.conformancetitle,md.dataquality.conformancedate,md.dataquality.conformancedatetype,md.dataquality.conformancedegree) -%}
+      <gmd:report>
+        <gmd:DQ_DomainConsistency xsi:type="gmd:DQ_DomainConsistency_Type">
+          <gmd:measureIdentification>
+            <gmd:RS_Identifier>
+              <gmd:code>
+                <gco:CharacterString>Conformity</gco:CharacterString>
+              </gmd:code>
+              <gmd:codeSpace>
+                <gco:CharacterString>INSPIRE</gco:CharacterString>
+              </gmd:codeSpace>
+            </gmd:RS_Identifier>
+          </gmd:measureIdentification>
+          <gmd:result>
+            <gmd:DQ_ConformanceResult xsi:type="gmd:DQ_ConformanceResult_Type">
+              <gmd:specification>
+                <gmd:CI_Citation>
+                  <gmd:title>
+                    <gco:CharacterString>{{ t }}</gco:CharacterString>
+                  </gmd:title>
+                  <gmd:date>
+                    <gmd:CI_Date>
+                      <gmd:date>
+                        <gco:Date>{{ d }}</gco:Date>
+                      </gmd:date>
+                      <gmd:dateType>
+                        <gmd:CI_DateTypeCode codeList="http://www.isotc211.org/2005/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue={{ "\"%s\"" % dt }}>{{ dt }}</gmd:CI_DateTypeCode>
+                      </gmd:dateType>
+                    </gmd:CI_Date>
+                  </gmd:date>
+                </gmd:CI_Citation>
+              </gmd:specification>
+              <gmd:explanation>
+                <gco:CharacterString>See the referenced specification</gco:CharacterString>
+              </gmd:explanation>
+              <gmd:pass>
+                <gco:Boolean>{{ dg }}</gco:Boolean>
+              </gmd:pass>
+            </gmd:DQ_ConformanceResult>
+          </gmd:result>
+        </gmd:DQ_DomainConsistency>
+      </gmd:report>
+      {% endfor -%}
+      <gmd:lineage>
+        <gmd:LI_Lineage>
+          <gmd:statement>
+            <gco:CharacterString>{{ md.dataquality.lineage }}</gco:CharacterString>
+          </gmd:statement>
+        </gmd:LI_Lineage>
+      </gmd:lineage>
+    </gmd:DQ_DataQuality>
+  </gmd:dataQualityInfo>
+</gmd:MD_Metadata>


Property changes on: sandbox/krejcmat/src/data/grassInspireTemplate.xml
___________________________________________________________________
Added: svn:executable
   + *

Added: sandbox/krejcmat/src/mdgrass.py
===================================================================
--- sandbox/krejcmat/src/mdgrass.py	                        (rev 0)
+++ sandbox/krejcmat/src/mdgrass.py	2014-06-12 22:26:32 UTC (rev 60812)
@@ -0,0 +1,469 @@
+#!/usr/bin/env python
+# -*- coding: utf-8
+
+"""
+AUTHOR(S): Matej Krejci <matejkrejci gmail.com>
+
+PURPOSE:   Library for creating ISO metadata for GRASS GIS
+
+COPYRIGHT: (C) 2007 Matej Krejci, and by the GRASS Development Team
+
+           This program is free software under the GNU General Public
+           License (>=v2). Read the file COPYING that comes with GRASS
+           for details.
+"""
+
+from owslib.iso import *
+from lxml import etree
+from jinja2 import Environment, FileSystemLoader
+
+import os
+import sys
+from grass.pygrass.modules.shortcuts import general as g
+from grass.pygrass.gis import Mapset
+from grass.pygrass import raster
+from grass.pygrass.modules import Module
+from grass.script import parse_key_val
+from subprocess import PIPE
+from datetime import date,datetime
+import getpass # whoami for linux and  ms-win
+from grass.script import parser
+from grass.script import core as grass
+import StringIO
+import subprocess as sub
+
+
+class GrassMD():
+    def __init__(self, map, type):
+
+        self.map = map                    #name of choosen map by user
+        self.type = type                  #typ of map representation(cell, vector, r3)
+        self.isMapExist()                 #function to check if map exist
+        self.md_grass = {}                #dict with metadata from r.info v.info  except "r.info flag=h"        
+        self.md_abstract = ''             #create abstract from self.md_grass - key: source1, source2 and descriptio etc.
+        self.md_vinfo_h = ''              #v.info flag=h" - parse
+        self.gisenv_grass = grass.gisenv()#dict with gisenv information
+        self.schema_type='_md_GRASS.xml'  #postfix of output xml file (variables)
+        self.dirpath = os.path.dirname(os.path.realpath(__file__))
+        self.md = MD_Metadata()            #metadata object from OWSLIB ( for define md values)
+        self.template = None               #path to file with xml templates
+        
+        if self.type == "cell":
+            self.parseRast()
+        elif self.type == "vector":
+            self.parseVect()
+        elif self.type == "r3??":
+            #TODO   
+            self.parseRast3D()
+            
+            
+    def isMapExist(self):
+        '''Check if is the map in working mapset'''    
+        self.mapset = grass.find_file(self.map, self.type)['mapset']
+        if not self.mapset:
+            grass.fatal(_("Map <%s> doesn't exist"), self.map)
+                   
+    def readXML(self,xml_file):
+        '''create instance of metadata(owslib) from xml file'''
+        self.md = MD_Metadata(etree.parse(xml_file))
+        
+    def parseRast3D(self):
+        pass
+    
+    def parseVect(self):
+        '''Read metadata from v.info
+        #self.md_grass dictionary of metadata from v.info '''
+        
+        #parse md from v.info flags=-g -e -t
+        vinfo = Module('v.info', self.map, flags='get', quiet = True, stdout_=PIPE)
+        self.md_grass = parse_key_val(vinfo.outputs.stdout)
+        
+        #parse md from v.info flag h (history of map in grass)
+        rinfo_h = Module('v.info', self.map, flags='h', quiet = True, stdout_=PIPE)
+        md_h_grass = rinfo_h.outputs.stdout
+        buf = StringIO.StringIO(md_h_grass)
+        line = buf.readline().splitlines()
+        while str(line) != '[]':   
+            if str(line[0]).strip() != "":             
+                self.md_vinfo_h += line[0] + '\n'
+            line = buf.readline().splitlines()
+        buf.close()
+        
+        #change grass generated date format to iso format
+        #if date format is diverse from standard, use them
+        self._createISODate('source_date')
+            
+    def _createISODate(self, key):
+        '''Function for convert grass-generated date to iso format
+           if the format of date is different to grass-generated format - use them and print warning  '''
+        
+        try:
+            date = datetime.strptime(self.md_grass[key], '%a %b %d %H:%M:%S %Y')
+            self.md_grass['dateofcreation'] = date.strftime('%Y-%m-%d')
+        except:
+            grass.warning('date of creation: unknown date format')
+            self.md_grass['dateofcreation'] = self.md_grass[key]
+                                
+    def parseRast(self):
+        '''Read metadata from r.info
+        #self.md_grass       dictionary of metadata from v.info 
+        #self.md_abstract    string created by merge information from 'description' and 'source'
+        '''
+        rinfo = Module('r.info', self.map, flags='gre', quiet = True, stdout_=PIPE)
+        self.md_grass = parse_key_val(rinfo.outputs.stdout)
+                   
+        #convert date to iso format
+        self._createISODate('date')
+            
+        #create abstract
+        if self.md_grass['description'] != '""':
+            self.md_abstract = self.md_grass['description'] + '\n'
+        if self.md_grass['source1'] != '""':
+            self.md_abstract += self.md_grass['source1'] + '\n'
+        if self.md_grass['source2'] != '""':
+            self.md_abstract += self.md_grass['source2'] +'\n'
+        self.md_abstract += 'Total cells: '+ self.md_grass['cells']
+        self.md_abstract += 'A range of values: min: ' + self.md_grass['min'] + '  max: ' + self.md_grass['max']
+        
+
+    def createGrassInspireISO(self):
+        '''Create valid INSPIRE profile and fill it as much as possible by GRASS metadata. Missing values is $NULL
+        -create basic md profile and add INSPIRE mandatory attributes
+        '''
+        
+        self.schema_type= '_md_INSPIRE.xml'
+        #create basic profile
+        self.createGrassBasicISO() 
+        self.template = 'data/grassInspireTemplate.xml'
+       
+        n = '$NULL'
+        self.md.datestamp = n
+        # Classification/Topic Category
+        self.md.identification.topiccategory.append(n)
+        self.md.identification.resourcelanguage.append(n)
+        
+        # Keyword/Keyword 
+        kw = {}
+        kw['keywords'] = []
+        kw['keywords'].append(n)
+        kw['keywords'].append(n)
+        kw['type'] = None
+        kw['thesaurus'] = {}
+        kw['thesaurus']['date'] = n
+        kw['thesaurus']['datetype'] = n
+        kw['thesaurus']['title'] = n
+        self.md.identification.keywords.append(kw)
+        # Conformity/Title 
+        self.md.dataquality.conformancetitle.pop() #remove value from basic profile
+        self.md.dataquality.conformancetitle.append('Commission Regulation (EU) No 1089/2010 of 23 November 2010 implementing Directive 2007/2/EC of the European Parliament and of the Council as regards interoperability of spatial data sets and services')
+        
+        # Conformity/Date 
+        self.md.dataquality.conformancedate.append(n)
+        self.md.dataquality.conformancedatetype.append(n)
+    
+         # Conformity/Degree 
+        self.md.dataquality.conformancedegree.append(n)
+        
+        # Constraints/Limitations on public access
+        self.md.identification.accessconstraints.append(n)
+        self.md.identification.otherconstraints.append(n)
+        
+        # Constraints/Conditions for access and use-general 
+        self.md.identification.uselimitation.append(n)
+        # Temporal/Temporal Extent 
+        self.md.identification.temporalextent_start = n
+        self.md.identification.temporalextent_end = n
+        
+    def createGrassBasicISO(self):
+        '''Create basic/essential profile based on ISO
+        - unknown values fill in by n = '$NULL'
+        '''
+        
+        n = '$NULL'
+        #jinja templates
+        self.template = 'data/grassBasicISOTemplate.xml'
+        #OWSLib md object 
+        self.md.identification = MD_DataIdentification()
+        self.md.dataquality = DQ_DataQuality()
+        self.md.distribution = MD_Distribution()
+        self.md.identification.extent = EX_Extent()
+        self.md.identification.extent.boundingBox = EX_GeographicBoundingBox()
+        
+        # Metadata on metadata
+        val = CI_ResponsibleParty()
+        val.organization = n
+        val.email = n
+        val.role = n
+        self.md.contact.append(val)
+        self.md.languagecode = n
+        
+        # Identification/Resource Title 
+        self.md.identification.title = self.md_grass['title']
+        self.md.datestamp = date.today().isoformat()
+        
+        # Identification/Resource Locator 
+        val = CI_OnlineResource()
+        val.url =n = '$NULL'
+        self.md.distribution.online.append(val)
+        
+        # Identification/Resource Type 
+        self.md.identification.identtype = 'dataset'
+        
+        # Identification/Unique Resource Identifier 
+        #TODO GENERATOR
+        self.md.identifier = '286c0725-146e-4533-b1bf-d6e367f6c342' 
+        self.md.identification.uricode.append('286c0725-146e-4533-b1bf-d6e367f6c342')
+        
+        #Geographic/BB
+        self.md.identification.extent.boundingBox.minx = self.md_grass['south']
+        self.md.identification.extent.boundingBox.maxx = self.md_grass['north']
+        self.md.identification.extent.boundingBox.miny = self.md_grass['west']
+        self.md.identification.extent.boundingBox.maxy = self.md_grass['east']
+        # Conformity/Title 
+        self.md.dataquality.conformancetitle.append('GRASS basic metadata profile based on ISO 19115, 19139')
+        # Conformity/Date:
+        self.md.dataquality.conformancedate.append(date.today().isoformat())
+        self.md.dataquality.conformancedatetype.append('publication')
+        
+        # Temporal/Date of creation 
+        val = CI_Date()
+        val.date = self.md_grass['dateofcreation']
+        val.type = 'creation'
+        self.md.identification.date.append(val)
+
+        #different metadata sources for vector and raster 
+        if self.type == 'cell':
+            # Identification/Resource Abstract 
+            self.md.identification.abstract = self.md_abstract
+            #Geographic/resolution
+            self.md.identification.uom.append(' ')
+            self.md.identification.distance.append(self.md_grass['nsres'])      #TODO for discuss
+
+            # Quality/Lineage
+            self.md.dataquality.lineage = self.md_grass['comments']
+            
+            # Organisation/Responsible Party:
+            val = CI_ResponsibleParty()
+            val.organization = getpass.getuser()
+            val.role = 'owner'
+            self.md.identification.contact.append(val)
+            
+        if self.type == 'vector':
+            # Identification/Resource Abstract 
+            self.md.identification.abstract = self.md_grass['name']  #TODO not enough sources for crate abstarce 
+            self.md.dataquality.lineage = self.md_vinfo_h
+            
+            # Organisation/Responsible Party:
+            val = CI_ResponsibleParty()
+            val.organization = self.md_grass['creator']
+            val.role = 'owner'
+            self.md.identification.contact.append(val)
+
+    def saveXML(self, path = None, xml_out_name = None):
+        ''' Save custom record to ISO XML file''' 
+        
+        #if  output file name is None, use map name and add postfix
+        if xml_out_name is None:
+            xml_out_name = str(self.map) + self.schema_type
+        if not xml_out_name.lower().endswith('.xml'):
+            xml_out_name +='.xml'
+        #if path is None, use lunch. dir
+        #TODO change default folder to mapset location
+        if not path:
+            path = os.path.join(self.dirpath,xml_out_name)
+        else:
+            path = os.path.join(path,xml_out_name)
+
+        #generate xml using jinja tempaltes
+        env = Environment(loader=FileSystemLoader(self.dirpath))
+        env.globals.update(zip=zip)
+        template = env.get_template(self.template)
+        iso_xml = template.render(md=self.md)
+        xml_file = xml_out_name
+        
+        #write xml to flat file
+        try:
+            xml_file = open(path, "w")
+            xml_file.write(iso_xml)
+            xml_file.close()
+            Module('g.message', message='metadata exported: \n\
+                                         %s'%(str(path)))
+        except IOError as e:
+            print "I/O error({0}): {1}".format(e.errno, e.strerror)
+            grass.fatal('error: cannot write xml file')
+        return  path
+    
+    def validate_inspire(self):
+        '''function for validation INSPIRE XML file'''
+        
+        result = {}
+        result["status"] = "succeded"
+        result["errors"] = []
+        result["num_of_errors"] = "0"
+        errors = 0
+    
+        if self.md.identification is None:
+            result["errors"].append("gself.md:CI_ResponsibleParty: Organization missing")
+            result["errors"].append("gself.md:CI_ResponsibleParty: E-mail missing")
+            result["errors"].append("gself.md:CI_ResponsibleParty: Role missing")
+            result["errors"].append("gself.md:self.md_DataIdentification: Title is missing")
+            result["errors"].append("gself.md:self.md_DataIdentification: Abstract is missing")
+            result["errors"].append("gself.md:self.md_ScopeCode: Resource Type is missing")
+            result["errors"].append("gself.md:language: Resource Language is missing")
+            result["errors"].append("gself.md:RS_Identifier: Unique Resource Identifier is missing")
+            result["errors"].append("gself.md:topicCategory: TopicCategory is missing")
+            result["errors"].append("gself.md:self.md_Keywords: Keywords are missing")
+            result["errors"].append("gself.md:thesaurusName: Thesaurus Title is missing")
+            result["errors"].append("gself.md:thesaurusName: Thesaurus Date is missing")
+            result["errors"].append("gself.md:thesaurusName: Thesaurus Date Type is missing")
+            result["errors"].append("gself.md:EX_Extent: extent element is missing")
+            result["errors"].append("gself.md:EX_GeographicBoundingBox: bbox is missing")
+            result["errors"].append("Both gself.md:EX_TemporalExtent and gself.md:CI_Date are missing")
+            result["errors"].append("gself.md:useLimitation is missing")
+            result["errors"].append("gself.md:accessConstraints is missing")
+            result["errors"].append("gself.md:otherConstraints is missing")
+            errors += 20
+        else:
+            if self.md.identification.contact is None or len(self.md.identification.contact) < 1:
+                result["errors"].append("gself.md:CI_ResponsibleParty: Organization missing")
+                result["errors"].append("gself.md:CI_ResponsibleParty: E-mail missing")
+                result["errors"].append("gself.md:CI_ResponsibleParty: Role missing")
+                errors += 3
+            else:
+                if self.md.identification.contact[0].organization is None:
+                    result["errors"].append("gself.md:CI_ResponsibleParty: Organization missing")
+                    errors += 1
+                if self.md.identification.contact[0].email is None:
+                    result["errors"].append("gself.md:CI_ResponsibleParty: E-mail missing")
+                    errors += 1
+                if self.md.identification.contact[0].role is None:
+                    result["errors"].append("gself.md:CI_ResponsibleParty: Role missing")
+                    errors += 1
+    
+            if self.md.identification.title is None:
+                result["errors"].append("gself.md:self.md_DataIdentification: Title is missing")
+                errors += 1
+            if self.md.identification.abstract is None:
+                result["errors"].append("gself.md:self.md_DataIdentification: Abstract is missing")
+                errors += 1
+            if self.md.identification.identtype is None:
+                result["errors"].append("gself.md:self.md_ScopeCode: Resource Type is missing")
+                errors += 1
+            if self.md.identification.resourcelanguage is None or len(self.md.identification.resourcelanguage) < 1:
+                result["errors"].append("gself.md:language: Resource Language is missing")
+                errors += 1
+            if self.md.identification.uricode is None or len(self.md.identification.uricode) < 1:
+                result["errors"].append("gself.md:RS_Identifier: Unique Resource Identifier is missing")
+                errors += 1
+            if self.md.identification.topiccategory is None or len(self.md.identification.topiccategory) < 1:
+                result["errors"].append("gself.md:topicCategory: TopicCategory is missing")
+                errors += 1
+            if self.md.identification.keywords is None or len(self.md.identification.keywords) < 1:
+                result["errors"].append("gself.md:self.md_Keywords: Keywords are missing")
+                result["errors"].append("gself.md:thesaurusName: Thesaurus Title is missing")
+                result["errors"].append("gself.md:thesaurusName: Thesaurus Date is missing")
+                result["errors"].append("gself.md:thesaurusName: Thesaurus Date Type is missing")
+                errors += 4
+            else:
+                if self.md.identification.keywords[0]['keywords'] is None or len(self.md.identification.keywords[0]['keywords']) < 1:
+                    result["errors"].append("gself.md:self.md_Keywords: Keywords are missing")
+                    errors += 1
+                if self.md.identification.keywords[0]['thesaurus'] is None:
+                    result["errors"].append("gself.md:thesaurusName: Thesaurus Title is missing")
+                    result["errors"].append("gself.md:thesaurusName: Thesaurus Date is missing")
+                    result["errors"].append("gself.md:thesaurusName: Thesaurus Date Type is missing")
+                    errors += 3
+                else:
+                    if self.md.identification.keywords[0]['thesaurus']['title'] is None:
+                        result["errors"].append("gself.md:thesaurusName: Thesaurus Title is missing")
+                        errors += 1
+                    if self.md.identification.keywords[0]['thesaurus']['date'] is None:
+                        result["errors"].append("gself.md:thesaurusName: Thesaurus Date is missing")
+                        errors += 1
+                    if self.md.identification.keywords[0]['thesaurus']['datetype'] is None:
+                        result["errors"].append("gself.md:thesaurusName: Thesaurus Date Type is missing")
+                        errors += 1
+            if self.md.identification.extent is None:
+                result["errors"].append("gself.md:EX_Extent: extent element is missing")
+                errors += 1
+            else:
+                if self.md.identification.extent.boundingBox is None:
+                    result["errors"].append("gself.md:EX_GeographicBoundingBox: bbox is missing")
+                    errors += 1
+                else:
+                    if self.md.identification.extent.boundingBox.minx is None:
+                        result["errors"].append("gself.md:westBoundLongitude: minx is missing")
+                        errors += 1
+                    if self.md.identification.extent.boundingBox.maxx is None:
+                        result["errors"].append("gself.md:eastBoundLongitude: maxx is missing")
+                        errors += 1
+                    if self.md.identification.extent.boundingBox.miny is None:
+                        result["errors"].append("gself.md:southBoundLatitude: miny is missing")
+                        errors += 1
+                    if self.md.identification.extent.boundingBox.maxy is None:
+                        result["errors"].append("gself.md:northBoundLatitude: maxy is missing")
+                        errors += 1
+            if len(self.md.identification.date) < 1 and (self.md.identification.temporalextent_start is None or self.md.identification.temporalextent_end is None):
+                result["errors"].append("Both gself.md:EX_TemporalExtent and gself.md:CI_Date are missing")
+                errors += 1
+            if len(self.md.identification.uselimitation) < 1:
+                result["errors"].append("gself.md:useLimitation is missing")
+                errors += 1
+            if len(self.md.identification.accessconstraints) < 1:
+                result["errors"].append("gself.md:accessConstraints is missing")
+                errors += 1
+            if len(self.md.identification.otherconstraints) < 1:
+                result["errors"].append("gself.md:otherConstraints is missing")
+                errors += 1
+    
+        if self.md.languagecode is None:
+            result["errors"].append("gself.md:LanguageCode: Language code missing")
+            errors += 1
+        if self.md.datestamp is None:
+            result["errors"].append("gself.md:dateStamp: Date is missing")
+            errors += 1
+        if self.md.identifier is None:
+            result["errors"].append("gself.md:identifier: Identifier is missing")
+            errors += 1
+        if self.md.dataquality is None:
+            result["errors"].append("gself.md:LI_Lineage is missing")
+            result["errors"].append("gself.md:DQ_ConformanceResult: date is missing")
+            result["errors"].append("gself.md:DQ_ConformanceResult: date type is missing")
+            # result["errors"].append("gself.md:DQ_ConformanceResult: degree is missing")
+            result["errors"].append("gself.md:DQ_ConformanceResult: title is missing")
+            errors += 4
+        else:
+            if self.md.dataquality.lineage is None:
+                result["errors"].append("gself.md:LI_Lineage is missing")
+                errors += 1
+            if len(self.md.dataquality.conformancedate) < 1:
+                result["errors"].append("gself.md:DQ_ConformanceResult: date is missing")
+                errors += 1
+            if len(self.md.dataquality.conformancedatetype) < 1:
+                result["errors"].append("gself.md:DQ_ConformanceResult: date type is missing")
+                errors += 1
+            # if len(self.md.dataquality.conformancedegree) < 1:
+            #     result["errors"].append("gself.md:DQ_ConformanceResult: degree is missing")
+            #     errors += 1
+            if len(self.md.dataquality.conformancetitle) < 1:
+                result["errors"].append("gself.md:DQ_ConformanceResult: title is missing")
+                errors += 1
+    
+        if self.md.contact is None:
+            result["errors"].append("gself.md:contact: Organization name is missing")
+            result["errors"].append("gself.md:contact: e-mail is missing")
+            errors += 2
+        else:
+            if self.md.contact[0].organization is None:
+                result["errors"].append("gself.md:contact: Organization name is missing")
+                errors += 1
+            if self.md.contact[0].email is None:
+                result["errors"].append("gself.md:contact: e-mail is missing")
+                errors += 1
+    
+        if errors > 0:
+            result["status"] = "failed"
+            result["num_of_errors"] = str(errors)
+    
+        return result
+


Property changes on: sandbox/krejcmat/src/mdgrass.py
___________________________________________________________________
Added: svn:executable
   + *

Added: sandbox/krejcmat/src/r.info.iso.py
===================================================================
--- sandbox/krejcmat/src/r.info.iso.py	                        (rev 0)
+++ sandbox/krejcmat/src/r.info.iso.py	2014-06-12 22:26:32 UTC (rev 60812)
@@ -0,0 +1,71 @@
+#!/usr/bin/env python
+# -*- coding: utf-8
+"""
+MODULE:    r.info.iso
+
+AUTHOR(S): Matej Krejci <matejkrejci gmail.com>
+
+PURPOSE:   Module for creating metadata based on ISO
+
+COPYRIGHT: (C) 2014 Matej Krejci, and by the GRASS Development Team
+
+           This program is free software under the GNU General Public
+           License (>=v2). Read the file COPYING that comes with GRASS
+           for details.
+"""
+#%option G_OPT_R_MAP
+#% key: map
+#% label: Name of input raster map
+#% required: yes
+#%end
+
+#%option
+#% key: profil
+#% label: Metadata profil based on ISO
+#% description: INSPIRE schema is not filled properly (unknown values are filled '$NULL')
+#% options: basic, inspire
+#% answer: basic
+#%end
+
+#%option G_OPT_R_MAP
+#% key: mdout
+#% label: Name of output metadata file
+#% required: no
+#%end
+
+#%option G_OPT_M_DIR 
+#% key: destination
+#% label: Path to destination folder
+#% required: no
+#%end
+
+from grass.script import parser
+from mdgrass import  *
+
+def main():
+
+    if not options['destination']:
+        destination = None
+    else:
+        destination = options['destination']
+        
+    if not options['mdout']:
+        mdout = None
+    else:
+        mdout=options['mdout']    
+  
+  
+    md = GrassMD(options['map'], 'cell')        
+    if options['profil']=='inspire':
+        md.createGrassInspireISO()
+        xml_file=md.saveXML(destination,mdout)
+        md.readXML(xml_file)
+        print md.validate_inspire()
+    else:    
+        md.createGrassBasicISO()
+        md.saveXML(destination,mdout)
+    
+
+if __name__ == "__main__":
+    options, flags = parser()
+    main()


Property changes on: sandbox/krejcmat/src/r.info.iso.py
___________________________________________________________________
Added: svn:executable
   + *

Added: sandbox/krejcmat/src/v.info.iso.py
===================================================================
--- sandbox/krejcmat/src/v.info.iso.py	                        (rev 0)
+++ sandbox/krejcmat/src/v.info.iso.py	2014-06-12 22:26:32 UTC (rev 60812)
@@ -0,0 +1,70 @@
+#!/usr/bin/env python
+# -*- coding: utf-8
+"""
+MODULE:    v.info.iso
+
+AUTHOR(S): Matej Krejci <matejkrejci gmail.com>
+
+PURPOSE:   Module for creating metadata based on ISO
+
+COPYRIGHT: (C) 2014 Matej Krejci, and by the GRASS Development Team
+
+           This program is free software under the GNU General Public
+           License (>=v2). Read the file COPYING that comes with GRASS
+           for details.
+"""
+#%option G_OPT_V_MAP
+#% key: map
+#% label: Name of input vector map
+#% required: yes
+#%end
+
+#%option
+#% key: profil
+#% label: Metadata profil based on ISO
+#% description: INSPIRE schema is not filled properly (unknown values are filled '$NULL')
+#% options: basic, inspire
+#% answer: basic
+#%end
+
+#%option G_OPT_V_MAP
+#% key: mdout
+#% label: Name of output metadata file
+#% required: no
+#%end
+
+#%option G_OPT_M_DIR 
+#% key: destination
+#% label: Path to destination folder
+#% required: no
+#%end
+
+from grass.script import parser
+from mdgrass import  *
+def main():
+
+    if not options['destination']:
+        destination = None
+    else:
+        destination = options['destination']
+        
+    if not options['mdout']:
+        mdout = None
+    else:
+        mdout=options['mdout']   
+    
+    #create instance of metadata in owslib
+    md = GrassMD(options['map'], 'vector') 
+           
+    if options['profil']=='inspire':
+        md.createGrassInspireISO()
+        xml_file=md.saveXML(options['destination'],options['mdout'])
+        md.readXML(xml_file)
+        print md.validate_inspire()
+    else:    
+        md.createGrassBasicISO()
+        md.saveXML(options['destination'],options['mdout'])
+    
+if __name__ == "__main__":
+    options, flags = parser()
+    main()


Property changes on: sandbox/krejcmat/src/v.info.iso.py
___________________________________________________________________
Added: svn:executable
   + *



More information about the grass-commit mailing list