Search in sources :

Example 1 with WKTGeometry

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

the class WKTConversionTest method testParseWKTString.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTConversion#parseWKTString(java.lang.String)}.
 */
@Test
public void testParseWKTString() {
    WKTGeometry geometry = WKTConversion.parseWKTString(null);
    assertNull(geometry);
    // CHECKSTYLE:OFF
    String wktString = "wkt://MULTILINESTRING((-0.25 -0.25, -0.125 -0.25), (0.125 -0.25, 0.25 -0.25), (-0.25 0.25, -0.125 0.25), (0.125 0.25, 0.25 0.25))";
    // CHECKSTYLE:ON
    geometry = WKTConversion.parseWKTString(wktString);
    assertNotNull(geometry);
    assertTrue(geometry.isValid());
    wktString = "LINESTRING(0.0 0.25, 0.25 0.25, 0.5 0.75, 0.75 0.25, 1.00 0.25)";
    geometry = WKTConversion.parseWKTString(wktString);
    assertNotNull(geometry);
    assertTrue(geometry.isValid());
    wktString = "POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))";
    geometry = WKTConversion.parseWKTString(wktString);
    assertNotNull(geometry);
    assertTrue(geometry.isValid());
    wktString = "wkt://POINT(40 0)";
    geometry = WKTConversion.parseWKTString(wktString);
    assertNotNull(geometry);
    assertTrue(geometry.isValid());
    wktString = "wkt://MULTIPOINT (10 40, 40 30, 20 20, 30 10)";
    geometry = WKTConversion.parseWKTString(wktString);
    assertNotNull(geometry);
    assertTrue(geometry.isValid());
    // CHECKSTYLE:OFF
    wktString = "MULTIPOLYGON (((30 20, 45 40, 10 40, 30 20)),((15 5, 40 10, 10 20, 5 10, 15 5)))";
    // CHECKSTYLE:ON
    geometry = WKTConversion.parseWKTString(wktString);
    assertNotNull(geometry);
    assertTrue(geometry.isValid());
    wktString = "MULTILINESTRING ((10 10, 20 20, 10 40),(40 40, 30 30, 40 20, 30 10))";
    geometry = WKTConversion.parseWKTString(wktString);
    assertNotNull(geometry);
    assertTrue(geometry.isValid());
    wktString = "invalid wkt string";
    geometry = WKTConversion.parseWKTString(wktString);
    assertNotNull(geometry);
    assertFalse(geometry.isValid());
}
Also used : WKTGeometry(com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTGeometry) Test(org.junit.Test)

Example 2 with WKTGeometry

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

the class WKTConversionTest method testGenerateWKTString.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTConversion#generateWKTString(com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTGeometry, boolean)}.
 */
@Test
public void testGenerateWKTString() {
    String actualString = WKTConversion.generateWKTString(null, false);
    assertNull(actualString);
    // CHECKSTYLE:OFF
    String wktString = "wkt://MULTILINESTRING((10 10, 20 20, 10 40),(40 40, 30 30, 40 20, 30 10))";
    // CHECKSTYLE:ON
    WKTGeometry geometry = WKTConversion.parseWKTString(wktString);
    assertNotNull(geometry);
    assertTrue(geometry.isValid());
    actualString = WKTConversion.generateWKTString(geometry, false);
    WKTGeometry geometry2 = WKTConversion.parseWKTString(actualString);
    @SuppressWarnings("unused") String // CHECKSTYLE:OFF
    actualString2 = WKTConversion.generateWKTString(geometry2, true);
    // CHECKSTYLE:ON
    // Can't compare because the WKT parser keeps swapping the 2 line strings around
    // assertEquals(geometry, geometry2);
    wktString = "LINESTRING(0.0 0.25, 0.25 0.25, 0.5 0.75, 0.75 0.25, 1.00 0.25)";
    geometry = WKTConversion.parseWKTString(wktString);
    assertNotNull(geometry);
    assertTrue(geometry.isValid());
    actualString = WKTConversion.generateWKTString(geometry, false);
    geometry2 = WKTConversion.parseWKTString(actualString);
    actualString2 = WKTConversion.generateWKTString(geometry2, false);
    assertEquals(geometry, geometry2);
    wktString = "POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))";
    geometry = WKTConversion.parseWKTString(wktString);
    assertNotNull(geometry);
    assertTrue(geometry.isValid());
    actualString = WKTConversion.generateWKTString(geometry, false);
    geometry2 = WKTConversion.parseWKTString(actualString);
    actualString2 = WKTConversion.generateWKTString(geometry2, false);
    assertEquals(geometry, geometry2);
    wktString = "wkt://POINT(40 0)";
    geometry = WKTConversion.parseWKTString(wktString);
    assertNotNull(geometry);
    assertTrue(geometry.isValid());
    actualString = WKTConversion.generateWKTString(geometry, false);
    geometry2 = WKTConversion.parseWKTString(actualString);
    actualString2 = WKTConversion.generateWKTString(geometry2, false);
    assertEquals(geometry, geometry2);
    wktString = "wkt://MULTIPOINT (10 40, 40 30, 20 20, 30 10)";
    geometry = WKTConversion.parseWKTString(wktString);
    assertNotNull(geometry);
    assertTrue(geometry.isValid());
    actualString = WKTConversion.generateWKTString(geometry, false);
    geometry2 = WKTConversion.parseWKTString(actualString);
    actualString2 = WKTConversion.generateWKTString(geometry2, false);
    // Can't compare because the points are added in a random order
    // assertEquals(geometry, geometry2);
    // CHECKSTYLE:OFF
    wktString = "wkt://MULTIPOLYGON(((30 20, 45 40, 10 40, 30 20)),((15 5, 40 10, 10 20, 5 10, 15 5)))";
    // CHECKSTYLE:ON
    geometry = WKTConversion.parseWKTString(wktString);
    assertNotNull(geometry);
    assertTrue(geometry.isValid());
    actualString = WKTConversion.generateWKTString(geometry, true);
    geometry2 = WKTConversion.parseWKTString(actualString);
    actualString2 = WKTConversion.generateWKTString(geometry2, true);
    // Can't compare because the WKT parser keeps swapping the 2 polygons around
    // assertEquals(geometry, geometry2);
    wktString = "MULTILINESTRING ((10 10, 20 20, 10 40),(40 40, 30 30, 40 20, 30 10))";
    geometry = WKTConversion.parseWKTString(wktString);
    assertNotNull(geometry);
    assertTrue(geometry.isValid());
    actualString = WKTConversion.generateWKTString(geometry, false);
    geometry2 = WKTConversion.parseWKTString(actualString);
    actualString2 = WKTConversion.generateWKTString(geometry2, false);
    // Can't compare because the WKT parser keeps swapping the 2 line around
    // assertEquals(geometry, geometry2);
    wktString = "invalid wkt string";
    geometry = WKTConversion.parseWKTString(wktString);
    assertNotNull(geometry);
    assertFalse(geometry.isValid());
    actualString = WKTConversion.generateWKTString(geometry, false);
    geometry2 = WKTConversion.parseWKTString(actualString);
    actualString2 = WKTConversion.generateWKTString(geometry2, false);
    assertEquals(geometry, geometry2);
}
Also used : WKTGeometry(com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTGeometry) Test(org.junit.Test)

Example 3 with WKTGeometry

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

the class WKTConversionTest method testCreateEmpty.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTConversion#createEmpty(com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTType)}.
 */
@Test
public void testCreateEmpty() {
    WKTType wktType = null;
    WKTGeometry geometry = WKTConversion.createEmpty(wktType);
    assertNull(geometry.getGeometryType());
    wktType = new WKTType("name", false, 5, "", false, true);
    geometry = WKTConversion.createEmpty(wktType);
    assertEquals(wktType, geometry.getGeometryType());
}
Also used : WKTGeometry(com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTGeometry) WKTType(com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTType) Test(org.junit.Test)

Example 4 with WKTGeometry

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

the class WKTGeometryTest method testHashCode.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTGeometry#hashCode()}.
 */
@Test
public void testHashCode() {
    WKTGeometry g = new WKTGeometry();
    String expectedListItem = "listitem";
    WKTType wktType = new WKTType("name", false, 5, expectedListItem, false, true);
    g.setGeometryType(wktType);
    g.addNewShape();
    g.addNewShape();
    g.addNewShape();
    WKTGeometry g2 = new WKTGeometry();
    g2.setGeometryType(wktType);
    g2.addNewShape();
    g2.addNewShape();
    assertTrue(g.hashCode() != g2.hashCode());
    assertTrue(g.equals(g));
    assertFalse(g.equals(null));
    assertFalse(g.equals(expectedListItem));
    WKTGeometry g3 = new WKTGeometry();
    WKTType wktType2 = new WKTType("name", false, 5, expectedListItem, true, true);
    g3.setGeometryType(wktType2);
    g3.addNewShape();
    g3.addNewShape();
    g3.addNewShape();
    assertFalse(g.equals(g3));
}
Also used : WKTGeometry(com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTGeometry) WKTType(com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTType) Test(org.junit.Test)

Example 5 with WKTGeometry

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

the class WKTGeometryTest method testIsValid.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTGeometry#isValid()}. Test
 * method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTGeometry#setValid(boolean)}.
 */
@Test
public void testIsValid() {
    WKTGeometry g = new WKTGeometry();
    assertTrue(g.isValid());
    assertTrue(g.isEmpty());
    g.setValid(false);
    assertFalse(g.isValid());
    g.setValid(true);
    assertTrue(g.isValid());
}
Also used : WKTGeometry(com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTGeometry) Test(org.junit.Test)

Aggregations

WKTGeometry (com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTGeometry)8 Test (org.junit.Test)8 WKTType (com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTType)5