dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #36522
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18678: Fixed wrongly formatted coordinates output for gml:coordinates nested within gml:Point elements.
------------------------------------------------------------
revno: 18678
committer: Halvdan Hoem Grelland <halvdanhg@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-03-24 17:52:51 +0100
message:
Fixed wrongly formatted coordinates output for gml:coordinates nested within gml:Point elements.
modified:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/gml/GmlConversionUtils.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/resources/gml/gml2dxf2.xsl
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/gml/GmlConversionUtils.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/gml/GmlConversionUtils.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/gml/GmlConversionUtils.java 2015-03-24 16:52:51 +0000
@@ -35,15 +35,15 @@
import java.util.Locale;
/**
- * Methods to parse various GML coordinate formats and output the DHIS 2 internal representation.
- * @author Halvdan Hoem Grelland
+ * Methods to parse various GML coordinate formats and output GeoJSON strings.
+ * @author Halvdan Hoem Grelland <halvdanhg@xxxxxxxxx>
*/
public class GmlConversionUtils
{
private static final NumberFormat NF = NumberFormat.getInstance( Locale.ENGLISH );
/**
- * Parses a gml:coordinates element and outputs the DHIS 2 internal string representation.
+ * Parses a gml:coordinates element and outputs a GeoJSON string.
*
* @param coordinates contents of gml:coordinates element to parse.
* @param precision decimal precision to use in output.
@@ -71,7 +71,7 @@
}
/**
- * Parses a gml:pos element and outputs the DHIS 2 internal string representation.
+ * Parses a gml:pos element and outputs a GeoJSON string.
*
* @param pos contents of gml:pos element to parse.
* @param precision decimal precision to use in output.
@@ -97,7 +97,7 @@
}
/**
- * Parses a gml:posList element and outputs the DHIS 2 internal string representation.
+ * Parses a gml:posList element and outputs a GeoJSON string.
*
* @param posList contents of gml:posList element to parse.
* @param precision decimal precision to use in output.
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/resources/gml/gml2dxf2.xsl'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/resources/gml/gml2dxf2.xsl 2015-03-10 12:47:37 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/resources/gml/gml2dxf2.xsl 2015-03-24 16:52:51 +0000
@@ -5,93 +5,98 @@
xmlns:java="org.hisp.dhis.dxf2.gml.GmlConversionUtils"
exclude-result-prefixes="java">
-<xsl:param name="precision">4</xsl:param>
-
-<xsl:template match="gml:coordinates">
- <xsl:text>[</xsl:text>
- <xsl:value-of select="java:gmlCoordinatesToString(normalize-space(.),$precision)"
- disable-output-escaping="yes"/>
- <xsl:text>]</xsl:text>
- <xsl:if test="position() != last()">
- <xsl:text>,</xsl:text>
- </xsl:if>
-</xsl:template>
-
-<xsl:template match="gml:pos">
- <xsl:value-of select="java:gmlPosToString(normalize-space(.),$precision)"
- disable-output-escaping="yes" />
-</xsl:template>
-
-<xsl:template match="gml:posList">
- <xsl:text>[</xsl:text>
- <xsl:value-of select="java:gmlPosListToString(normalize-space(.),$precision)"
- disable-output-escaping="yes"/>
- <xsl:text>]</xsl:text>
- <xsl:if test="position() != last()">
- <xsl:text>,</xsl:text>
- </xsl:if>
-</xsl:template>
-
-<xsl:template match="gml:Polygon">
- <featureType>Polygon</featureType>
- <coordinates>
- <xsl:text>[[</xsl:text>
- <xsl:apply-templates select=".//gml:coordinates"/>
+ <xsl:param name="precision">4</xsl:param>
+
+ <xsl:template match="gml:coordinates" mode="multipleCoordinates">
+ <xsl:text>[</xsl:text>
+ <xsl:value-of select="java:gmlCoordinatesToString(normalize-space(.),$precision)"
+ disable-output-escaping="yes"/>
+ <xsl:text>]</xsl:text>
+ <xsl:if test="position() != last()">
+ <xsl:text>,</xsl:text>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="gml:coordinates" mode="singleCoordinate">
+ <xsl:value-of select="java:gmlCoordinatesToString(normalize-space(.),$precision)"
+ disable-output-escaping="yes"/>
+ </xsl:template>
+
+ <xsl:template match="gml:pos">
+ <xsl:value-of select="java:gmlPosToString(normalize-space(.),$precision)"
+ disable-output-escaping="yes" />
+ </xsl:template>
+
+ <xsl:template match="gml:posList">
+ <xsl:text>[</xsl:text>
+ <xsl:value-of select="java:gmlPosListToString(normalize-space(.),$precision)"
+ disable-output-escaping="yes"/>
+ <xsl:text>]</xsl:text>
+ <xsl:if test="position() != last()">
+ <xsl:text>,</xsl:text>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="gml:Polygon">
+ <featureType>Polygon</featureType>
+ <coordinates>
+ <xsl:text>[[</xsl:text>
+ <xsl:apply-templates select=".//gml:coordinates" mode="multipleCoordinates"/>
+ <xsl:apply-templates select=".//gml:posList"/>
+ <xsl:text>]]</xsl:text>
+ <xsl:if test="position() != last()">
+ <xsl:text>,</xsl:text>
+ </xsl:if>
+ </coordinates>
+ </xsl:template>
+
+ <xsl:template match="gml:MultiPolygon">
+ <featureType>MultiPolygon</featureType>
+ <coordinates>
+ <xsl:text>[</xsl:text>
+ <xsl:apply-templates select=".//gml:polygonMember"/>
+ <xsl:text>]</xsl:text>
+ </coordinates>
+ </xsl:template>
+
+ <xsl:template match="gml:Point">
+ <featureType>Point</featureType>
+ <coordinates>
+ <xsl:apply-templates select=".//gml:coordinates" mode="singleCoordinate"/>
+ <xsl:apply-templates select=".//gml:pos"/>
+ </coordinates>
+ </xsl:template>
+
+ <xsl:template match="gml:polygonMember">
+ <xsl:text>[</xsl:text>
+ <xsl:apply-templates select=".//gml:coordinates" mode="multipleCoordinates"/>
<xsl:apply-templates select=".//gml:posList"/>
- <xsl:text>]]</xsl:text>
+ <xsl:text>]</xsl:text>
<xsl:if test="position() != last()">
<xsl:text>,</xsl:text>
</xsl:if>
- </coordinates>
-</xsl:template>
-
-<xsl:template match="gml:MultiPolygon">
- <featureType>MultiPolygon</featureType>
- <coordinates>
- <xsl:text>[</xsl:text>
- <xsl:apply-templates select=".//gml:polygonMember"/>
- <xsl:text>]</xsl:text>
- </coordinates>
-</xsl:template>
-
-<xsl:template match="gml:Point">
- <featureType>Point</featureType>
- <coordinates>
- <xsl:apply-templates select=".//gml:coordinates"/>
- <xsl:apply-templates select=".//gml:pos"/>
- </coordinates>
-</xsl:template>
-
-<xsl:template match="gml:polygonMember">
- <xsl:text>[[</xsl:text>
- <xsl:apply-templates select=".//gml:coordinates"/>
- <xsl:apply-templates select=".//gml:posList"/>
- <xsl:text>]]</xsl:text>
- <xsl:if test="position() != last()">
- <xsl:text>,</xsl:text>
- </xsl:if>
-</xsl:template>
-
-<xsl:template match="gml:featureMember">
- <xsl:variable name="name" select=".//*[local-name()='Name' or local-name()='NAME' or local-name()='name']"/>
- <organisationUnit>
- <xsl:attribute name="name">
- <xsl:value-of select="$name"/>
- </xsl:attribute>
- <xsl:attribute name="shortName">
- <xsl:value-of select="substring($name,1,50)"/>
- </xsl:attribute>
- <xsl:apply-templates select="./child::node()/child::node()/gml:Polygon|./child::node()/child::node()/gml:MultiPolygon|./child::node()/child::node()/gml:Point"/>
- <active>true</active>
- </organisationUnit>
-</xsl:template>
-
-<xsl:template match="/">
- <dxf xmlns="http://dhis2.org/schema/dxf/2.0">
- <organisationUnits>
- <xsl:apply-templates select=".//gml:featureMember"/>
- </organisationUnits>
- </dxf>
-</xsl:template>
+ </xsl:template>
+
+ <xsl:template match="gml:featureMember">
+ <xsl:variable name="name" select=".//*[local-name()='Name' or local-name()='NAME' or local-name()='name']"/>
+ <organisationUnit>
+ <xsl:attribute name="name">
+ <xsl:value-of select="$name"/>
+ </xsl:attribute>
+ <xsl:attribute name="shortName">
+ <xsl:value-of select="substring($name,1,50)"/>
+ </xsl:attribute>
+ <xsl:apply-templates select="./child::node()/child::node()/gml:Polygon|./child::node()/child::node()/gml:MultiPolygon|./child::node()/child::node()/gml:Point"/>
+ <active>true</active>
+ </organisationUnit>
+ </xsl:template>
+
+ <xsl:template match="/">
+ <dxf xmlns="http://dhis2.org/schema/dxf/2.0">
+ <organisationUnits>
+ <xsl:apply-templates select=".//gml:featureMember"/>
+ </organisationUnits>
+ </dxf>
+ </xsl:template>
</xsl:stylesheet>