Search in sources :

Example 1 with WKTPoint

use of com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTPoint in project sldeditor by robward-scisys.

the class WKTPointModelTest method testPopulateWKTSegmentList.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTPointModel#setWKTType(com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTType)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTPointModel#populate(com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTSegmentList)}.
 */
@Test
public void testPopulateWKTSegmentList() {
    WKTSegmentList segmentList = new WKTSegmentList();
    DirectPosition pos1 = new DirectPosition2D(1.0, 1.0);
    DirectPosition pos2 = new DirectPosition2D(2.0, 2.0);
    DirectPosition pos3 = new DirectPosition2D(3.0, 3.0);
    DirectPosition pos4 = new DirectPosition2D(4.0, 4.0);
    segmentList.addPoint(new WKTPoint(pos1));
    segmentList.addPoint(new WKTPoint(pos2));
    segmentList.addPoint(new WKTPoint(pos3));
    segmentList.addPoint(new WKTPoint(pos4));
    WKTPointModel model = new WKTPointModel();
    WKTType wktType = new WKTType("name", false, 5, "", false, false);
    model.setWKTType(wktType);
    model.populate(null);
    assertTrue(model.getRowCount() == 0);
    model.populate(segmentList);
    assertTrue(model.getRowCount() == 4);
    model.populate(segmentList);
    assertTrue(model.getRowCount() == 4);
    segmentList.addPoint(new WKTPoint(pos1));
    assertTrue(model.getRowCount() == 5);
    // Set WKTType to null is the same as first and last points flag = false
    model.setWKTType(null);
    model.populate(segmentList);
    assertTrue(model.getRowCount() == 5);
}
Also used : DirectPosition(org.opengis.geometry.DirectPosition) WKTPointModel(com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTPointModel) WKTSegmentList(com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTSegmentList) WKTType(com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTType) WKTPoint(com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTPoint) DirectPosition2D(org.geotools.geometry.DirectPosition2D) Test(org.junit.Test)

Example 2 with WKTPoint

use of com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTPoint in project sldeditor by robward-scisys.

the class WKTPointTest method testWKTPointDirectPosition.

/**
 * Test method for {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTPoint#WKTPoint(org.opengis.geometry.DirectPosition)}.
 * Test method for {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTPoint#WKTPoint()}.
 * Test method for {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTPoint#getX()}.
 * Test method for {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTPoint#getY()}.
 * Test method for {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTPoint#setX(double)}.
 * Test method for {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTPoint#setY(double)}.
 * Test method for {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTPoint#equals(java.lang.Object)}.
 */
@Test
public void testWKTPointDirectPosition() {
    WKTPoint point = new WKTPoint();
    assertTrue(Math.abs(point.getX() - 0.0) < 0.001);
    assertTrue(Math.abs(point.getY() - 0.0) < 0.001);
    point = new WKTPoint(null);
    assertTrue(Math.abs(point.getX() - 0.0) < 0.001);
    assertTrue(Math.abs(point.getY() - 0.0) < 0.001);
    double x = 45.2;
    double y = -3.1;
    DirectPosition pos = new DirectPosition2D(x, y);
    point = new WKTPoint(pos);
    assertTrue(Math.abs(point.getX() - x) < 0.001);
    assertTrue(Math.abs(point.getY() - y) < 0.001);
    x = 42.0;
    point.setX(x);
    assertTrue(Math.abs(point.getX() - x) < 0.001);
    y = 42.0;
    point.setY(y);
    assertTrue(Math.abs(point.getY() - y) < 0.001);
    DirectPosition pos2 = new DirectPosition2D(x, y);
    WKTPoint point2 = new WKTPoint(pos2);
    assertTrue(point.equals(point2));
    point2.setX(3.14);
    assertFalse(point.equals(point2));
    assertFalse(point.equals(null));
    assertFalse(point.equals(pos2));
    assertTrue(point.equals(point));
    assertTrue(point.hashCode() != point2.hashCode());
}
Also used : DirectPosition(org.opengis.geometry.DirectPosition) WKTPoint(com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTPoint) DirectPosition2D(org.geotools.geometry.DirectPosition2D) Test(org.junit.Test)

Example 3 with WKTPoint

use of com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTPoint in project sldeditor by robward-scisys.

the class WKTSegmentListTest method testGetWktPointList.

/**
 * Test method for {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTSegmentList#getWktPointList(boolean)}.
 * Test method for {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTSegmentList#setWktPointList(java.util.List)}.
 * Test method for {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTSegmentList#addPoint(com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTPoint)}.
 * Test method for {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTSegmentList#getWKTString()}.
 * Test method for {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTSegmentList#getWKTString(boolean)}.
 */
@Test
public void testGetWktPointList() {
    WKTSegmentList segmentList = new WKTSegmentList();
    DirectPosition pos1 = new DirectPosition2D(1.0, 1.0);
    segmentList.addPoint(new WKTPoint(pos1));
    String actualValue = segmentList.getWKTString();
    assertTrue(actualValue.compareTo("(1 1)") == 0);
    List<WKTPoint> ptList = new ArrayList<WKTPoint>();
    ptList.add(new WKTPoint(pos1));
    DirectPosition pos2 = new DirectPosition2D(2.0, 2.0);
    DirectPosition pos3 = new DirectPosition2D(3.0, 3.0);
    DirectPosition pos4 = new DirectPosition2D(4.0, 4.0);
    ptList.add(new WKTPoint(pos2));
    ptList.add(new WKTPoint(pos3));
    ptList.add(new WKTPoint(pos4));
    segmentList.setWktPointList(ptList);
    actualValue = segmentList.getWKTString();
    assertTrue(actualValue.compareTo("(1 1, 2 2, 3 3, 4 4)") == 0);
    actualValue = segmentList.getWKTString(false, false);
    assertTrue(actualValue.compareTo("1 1, 2 2, 3 3, 4 4") == 0);
    actualValue = segmentList.getWKTString(false, true);
    assertTrue(actualValue.compareTo("1 1, 2 2, 3 3, 4 4, 1 1") == 0);
    ptList.add(new WKTPoint(pos1));
    segmentList.setWktPointList(ptList);
    assertTrue(segmentList.getWktPointList(false).size() == ptList.size());
    assertTrue((segmentList.getWktPointList(true).size() + 1) == ptList.size());
    ptList.clear();
    ptList.add(new WKTPoint(pos1));
    assertTrue(segmentList.getWktPointList(false).size() == ptList.size());
    assertTrue(segmentList.getWktPointList(true).size() == ptList.size());
    segmentList.addPoint(new WKTPoint(pos2));
    assertTrue(segmentList.getWktPointList(false).size() == ptList.size());
    assertTrue(segmentList.getWktPointList(true).size() == ptList.size());
}
Also used : DirectPosition(org.opengis.geometry.DirectPosition) WKTSegmentList(com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTSegmentList) ArrayList(java.util.ArrayList) WKTPoint(com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTPoint) DirectPosition2D(org.geotools.geometry.DirectPosition2D) Test(org.junit.Test)

Aggregations

WKTPoint (com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTPoint)3 DirectPosition2D (org.geotools.geometry.DirectPosition2D)3 Test (org.junit.Test)3 DirectPosition (org.opengis.geometry.DirectPosition)3 WKTSegmentList (com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTSegmentList)2 WKTPointModel (com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTPointModel)1 WKTType (com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTType)1 ArrayList (java.util.ArrayList)1