Project

General

Profile

Download (1.13 KB) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.cdm.remote.editor;
2

    
3
import java.beans.PropertyEditorSupport;
4

    
5
import org.hibernate.search.spatial.impl.Point;
6
import org.hibernate.search.spatial.impl.Rectangle;
7
import org.springframework.util.Assert;
8

    
9
/**
10
 * BBOX=minx(minlongitute),miny(minlatitute),maxx(maxlongitute),max(maxlatitute): Bounding box corners (lower left, upper right)
11
 *
12
 * @author a.kohlbecker
13
 * @since Apr 26, 2013
14
 *
15
 */
16
public class RectanglePropertyEditor extends PropertyEditorSupport {
17

    
18
    /*
19
     * (non-Javadoc)
20
     *
21
     * @see java.beans.PropertyEditorSupport#setAsText(java.lang.String)
22
     */
23
    @Override
24
    public void setAsText(String text) {
25
        String[] values = text.split(",");
26
        Assert.isTrue(values.length == 4, "A rectangle string must contain four values");
27
        setValue(new Rectangle(
28
                // Points are constructed as : latitude, longitude
29
                Point.fromDegreesInclusive(Double.parseDouble(values[1]), Double.parseDouble(values[0])),
30
                Point.fromDegreesInclusive(Double.parseDouble(values[3]), Double.parseDouble(values[2]))
31
              ));
32
    }
33

    
34
}
(13-13/19)