Search in sources :

Example 1 with WKTSegmentList

use of com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTSegmentList 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 WKTSegmentList

use of com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTSegmentList 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)2 WKTSegmentList (com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTSegmentList)2 DirectPosition2D (org.geotools.geometry.DirectPosition2D)2 Test (org.junit.Test)2 DirectPosition (org.opengis.geometry.DirectPosition)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