dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #14665
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5059: Put back the rounding on gml coordinate import. Currently its set to 4 decimal places. If you wa...
------------------------------------------------------------
revno: 5059
committer: Bob Jolliffe bobjolliffe@xxxxxxxxx
branch nick: dhis2
timestamp: Fri 2011-10-28 13:24:59 +0100
message:
Put back the rounding on gml coordinate import. Currently its set to 4 decimal places. If you want to change it see the parameter at top of gml2dxf file.
modified:
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/Util.java
dhis-2/dhis-services/dhis-service-importexport/src/main/resources/transform/gml2dxf.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-importexport/src/main/java/org/hisp/dhis/importexport/xml/Util.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/Util.java 2011-09-23 18:54:49 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/Util.java 2011-10-28 12:24:59 +0000
@@ -70,15 +70,20 @@
* @param coordinates
* @return
*/
- public static String gmlToCoords(String coordinates)
+ public static String gmlToCoords(String coordinates, String decimalPlacesAsString)
{
+ int decimalPlaces = Integer.parseInt( decimalPlacesAsString);
+ String formatString = "%."+decimalPlaces+"f,%."+decimalPlaces+"f";
StringBuilder sb = new StringBuilder();
String[] coords = coordinates.split( "\\s");
- for (String coord : coords)
+ for (String coordAsString : coords)
{
+ String[] latlon = coordAsString.split( ",");
+ double lat = Double.parseDouble( latlon[0] );
+ double lon = Double.parseDouble( latlon[1] );
sb.append( "<coord>");
- sb.append( coord);
+ sb.append( String.format(formatString, lat, lon));
sb.append( "</coord>");
}
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/resources/transform/gml2dxf.xsl'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/resources/transform/gml2dxf.xsl 2011-09-20 22:27:02 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/resources/transform/gml2dxf.xsl 2011-10-28 12:24:59 +0000
@@ -4,11 +4,11 @@
xmlns:gml="http://www.opengis.net/gml"
>
-<xsl:param name="roundingFactor">10000</xsl:param>
+<xsl:param name="decimalPlaces">4</xsl:param>
<xsl:template match="gml:coordinates">
<coordinatesTuple>
- <xsl:value-of select="dhis:gmlToCoords(normalize-space(.))"
+ <xsl:value-of select="dhis:gmlToCoords(normalize-space(.),$decimalPlaces)"
disable-output-escaping="yes"
xmlns:dhis="org.hisp.dhis.importexport.xml.Util" />
</coordinatesTuple>
@@ -59,4 +59,4 @@
</xsl:template>
-</xsl:stylesheet>
\ No newline at end of file
+</xsl:stylesheet>