se.vgregion.mobile.hriv.utils.GeoUtil Maven / Gradle / Ivy
The newest version!
/**
* Copyright 2010 Västra Götalandsregionen
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of version 2.1 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*/
package se.vgregion.mobile.hriv.utils;
import java.util.Scanner;
/**
* Utility-class for geographically related conversions etc.
*/
public abstract class GeoUtil {
/**
* Parses an RT90 formatted string.
*
* @param rt90String HSA formatted RT90 coords: X: 1234567, Y: 1234567.
* @return An array of RT90 coordinates.
*/
public static int[] parseRT90HsaString(String rt90String) {
int[] result = null;
if (!"".equals(rt90String)) {
if (rt90String.indexOf("X:") >= 0 && rt90String.indexOf("Y:") >= 0) {
Scanner scanner = new Scanner(rt90String);
int rt90X = Integer.parseInt(scanner.findInLine("\\d+"));
int rt90Y = Integer.parseInt(scanner.findInLine("\\d+"));
result = new int[]{rt90X, rt90Y};
}
}
return result;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy