Skip to content

Commit

Permalink
Add draw bbox directive for Dublin-Core
Browse files Browse the repository at this point in the history
  • Loading branch information
fgravin committed Jan 21, 2014
1 parent 8d8a74b commit 16bd893
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 6 deletions.
Expand Up @@ -18,13 +18,24 @@
hbottomRef: '@',
hleftRef: '@',
hrightRef: '@',
dcRef: '@',
lang: '='
},
link: function(scope, element, attrs) {
scope.drawing = false;
var mapRef = scope.htopRef || scope.dcRef;
scope.mapId = 'map-drawbbox-' +
scope.htopRef.substring(1, scope.htopRef.length);
mapRef.substring(1, mapRef.length);

/**
* set dublin-core coverage output
*/
var setDcOutput = function() {
if(scope.dcRef) {
scope.dcExtent = gnMap.getDcExtent(scope.extent.md);
}
};

/**
* Different projections used in the directive:
* - md : the proj system in the metadata. It is defined as
Expand Down Expand Up @@ -58,7 +69,8 @@
// Init extent from md for map and form
reprojExtent('md', 'map');
reprojExtent('md', 'form');

setDcOutput();

scope.$watch('projs.form', function(newValue, oldValue) {
scope.extent.form = gnMap.reprojExtent(
scope.extent.form, oldValue, newValue
Expand Down Expand Up @@ -123,6 +135,7 @@
scope.$apply(function() {
reprojExtent('map', 'form');
reprojExtent('map', 'md');
setDcOutput();
});
});

Expand All @@ -144,7 +157,6 @@
scope.extent.map);
geom = new ol.geom.Polygon(coordinates);
}

feature.setGeometry(geom);
feature.getGeometry().setCoordinates(coordinates);
};
Expand Down Expand Up @@ -180,7 +192,7 @@

reprojExtent('form', 'map');
reprojExtent('form', 'md');

setDcOutput();
drawBbox();
};

Expand All @@ -197,8 +209,10 @@

reprojExtent('md', 'map');
reprojExtent('md', 'form');
setDcOutput();
drawBbox();
map.getView().fitExtent(scope.extent.map, map.getSize()); };
map.getView().fitExtent(scope.extent.map, map.getSize());
};
}
};
}]);
Expand Down
Expand Up @@ -64,7 +64,22 @@
return new ol.layer.Tile({
source: source
});
}
},

/**
* Transform map extent into dublin-core schema for
* dc:coverage metadata element.
* Ex :
* North 90, South -90, East 180, West -180. Global
*/
getDcExtent : function(extent) {
var dc = 'North ' + extent[3] + ', ' +
'South ' + extent[1] + ', ' +
'East ' + extent[0] + ', ' +
'West ' + extent[2] + '. Global';

return dc;
},
};
}];
});
Expand Down
Expand Up @@ -34,6 +34,7 @@
<input data-ng-model="extent.form[1]" type="" name="{{hbottomRef}}"/>
<input data-ng-model="extent.form[2]" type="" name="{{hrightRef}}"/>
<input data-ng-model="extent.form[3]" type="" name="{{htopRef}}"/>
<input data-ng-model="dcExtent" type="" name="{{dcRef}}"/>
</div>
<table class="text-center">
<tr align="center">
Expand Down
Expand Up @@ -153,5 +153,40 @@
</xsl:call-template>

</xsl:template>

<xsl:template mode="mode-dublin-core" match="dc:coverage" priority="2000">
<xsl:param name="schema" select="$schema" required="no"/>
<xsl:param name="labels" select="$labels" required="no"/>

<xsl:variable name="coverage" select="."/>
<xsl:variable name="n" select="substring-after($coverage,'North ')"/>
<xsl:variable name="north" select="substring-before($n,',')"/>
<xsl:variable name="s" select="substring-after($coverage,'South ')"/>
<xsl:variable name="south" select="substring-before($s,',')"/>
<xsl:variable name="e" select="substring-after($coverage,'East ')"/>
<xsl:variable name="east" select="substring-before($e,',')"/>
<xsl:variable name="w" select="substring-after($coverage,'West ')"/>
<xsl:variable name="west" select="substring-before($w,'. ')"/>
<xsl:variable name="p" select="substring-after($coverage,'(')"/>
<xsl:variable name="place" select="substring-before($p,')')"/>

<xsl:call-template name="render-boxed-element">
<xsl:with-param name="label"
select="gn-fn-metadata:getLabel($schema, name(), $labels, name(..),'','')/label"/>
<xsl:with-param name="editInfo" select="gn:element"/>
<xsl:with-param name="cls" select="local-name()"/>
<!-- <xsl:with-param name="attributesSnippet" select="$attributes"/> -->
<xsl:with-param name="subTreeSnippet">
<div gn-draw-bbox=""
data-hleft="{$west}"
data-hright="{$east}"
data-hbottom="{$south}"
data-htop="{$north}"
data-dc-ref="_{gn:element/@ref}"
data-lang="lang"></div>
</xsl:with-param>
</xsl:call-template>
</xsl:template>


</xsl:stylesheet>

0 comments on commit 16bd893

Please sign in to comment.