/[schmitzm]/branches/2.3.KECK/src/skrueger/openlayers/OpenLayersUtil.java
ViewVC logotype

Annotation of /branches/2.3.KECK/src/skrueger/openlayers/OpenLayersUtil.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1103 - (hide annotations)
Thu Oct 14 09:45:14 2010 UTC (14 years, 4 months ago) by alfonx
File MIME type: text/plain
File size: 1194 byte(s)


1 alfonx 773 package skrueger.openlayers;
2    
3 alfonx 934 import java.util.regex.Matcher;
4 alfonx 773 import java.util.regex.Pattern;
5    
6 alfonx 934 import org.geotools.resources.geometry.XRectangle2D;
7    
8 alfonx 773 final public class OpenLayersUtil {
9    
10 alfonx 934 /**
11     * A REGEX pattern to interpret the string representation of an
12     * Openlayer.Bounds object
13     **/
14 alfonx 773 public final static Pattern OPENLAYERS_BOUNDS_FROM_STRING_REGEX = Pattern
15     .compile("left-bottom=\\((.*)?,(.*)?\\) right-top=\\((.*)?,(.*)?\\).*");
16 alfonx 934
17     /**
18     * Ein OpenLayers.Bounds-Object welches als String übergeben wurde, kann mit
19     * dieser Methode geparsed und in Double-Koordinaten umgewandelt werden. Die
20     * Methode liefert <code>null</code> wenn das REGEX Muster nicht auf den
21     * String passt.
22     */
23     public static XRectangle2D parseBounds(String olBoundsString) {
24     Matcher matcher = OpenLayersUtil.OPENLAYERS_BOUNDS_FROM_STRING_REGEX
25     .matcher(olBoundsString);
26     if (matcher.find()) {
27     double x1 = Double.parseDouble(matcher.group(1));
28     double y1 = Double.parseDouble(matcher.group(2));
29     double x2 = Double.parseDouble(matcher.group(3));
30     double y2 = Double.parseDouble(matcher.group(4));
31    
32     return new XRectangle2D(x1, y1, x2 - x1, y2 - y1);
33     } else {
34     return null;
35     }
36     }
37 alfonx 773 }

Properties

Name Value
svn:eol-style native
svn:keywords Id URL
svn:mime-type text/plain

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26