Package chunmap.model.relate.relateop

Source Code of chunmap.model.relate.relateop.LineString_LineStringTest

/**
* Copyright (c) 2009-2011, chunquedong(YangJiandong)
*
* This file is part of ChunMap project
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE(Version >=3)
*
* History:
*     2010-05-05  Jed Young  Creation
*/
package chunmap.model.relate.relateop;

import static org.junit.Assert.*;

import org.junit.Test;

import chunmap.model.geom.Geometry;
import chunmap.model.geom.LineString;
import chunmap.model.geom.WktReader;
import chunmap.model.relate.ComputeImFactory;
import chunmap.model.relate.IntersectionMatrix;

public class LineString_LineStringTest {

  @Test
  public void testGetIM() {
    WktReader wkt = new WktReader();
    Geometry g = wkt.read("LINESTRING(1 1,1 2,2 2,3 2)");
    LineString ls = (LineString) g;
    Geometry g2 = wkt.read("LINESTRING(1 2,2 2,3 2,4 2)");
    LineString ls2 = (LineString) g2;
    Geometry g3 = wkt.read("LINESTRING(1 2,2 2,3 2)");
    LineString ls3 = (LineString) g3;
    Geometry g4 = wkt.read("LINESTRING(2 0,2 2,3 3)");
    LineString ls4 = (LineString) g4;

    IntersectionMatrix rt = ComputeImFactory.getInstance().getImComputer(
        ls, ls2).getIM();
    // LineString_LineString l2l = new LineString_LineString(ls, ls2);
    // IntersectionMatrix rt = l2l.getIM();
    assertTrue(rt.match(IntersectionMatrix.OverlapPatternLL));

    IntersectionMatrix rt2 = ComputeImFactory.getInstance().getImComputer(
        ls3, ls).getIM();
    assertTrue(rt2.match(IntersectionMatrix.WithinsPattern));

    IntersectionMatrix rt3 = ComputeImFactory.getInstance().getImComputer(
        ls4, ls).getIM();
    assertTrue(rt3.match(IntersectionMatrix.CrossesPatternLL));
  }

  @Test
  public void testGetIM2() {
    WktReader wkt = new WktReader();
    Geometry g = wkt.read("LINESTRING(1.0 1.0,1.0 2.0,2.0 2.0,3.0 2.0)");
    LineString ls = (LineString) g;
    Geometry g2 = wkt
        .read("LINESTRING(1.0 2.0,3.0 1.0,4.0 0.0,3.0 -2.0,0.0 0.0,1.0 2.0)");
    LineString ls2 = (LineString) g2;

    IntersectionMatrix rt = ComputeImFactory.getInstance().getImComputer(
        ls2, ls).getIM();
    // LineString_LineString l2l = new LineString_LineString(ls, ls2);
    // IntersectionMatrix rt = l2l.getIM();
    assertTrue(!rt.match(IntersectionMatrix.DisjointPattern));
  }

  @Test
  public void testGetIM3() {
    WktReader wkt = new WktReader();
    Geometry g = wkt.read("LINESTRING(2.0 2.0,0.0 0.0)");
    LineString ls = (LineString) g;
    Geometry g2 = wkt
        .read("LINESTRING(0.98 0.94,1.0466666666666666 0.94,1.0466666666666666 1.0066666666666666,0.98 1.0066666666666666,0.98 0.94)");
    LineString ls2 = (LineString) g2;

    // IntersectionMatrix rt = ComputeImFactory.getInstance().getImComputer(
    // ls2, ls).getIM();
    LineString_LineString l2l = new LineString_LineString(ls, ls2);
    IntersectionMatrix rt = l2l.getIM();
    assertTrue(rt.get(IntersectionMatrix.Inner, IntersectionMatrix.Inner) != IntersectionMatrix.EmptyDim);
  }

  @Test
  public void testGetIM4() {
    WktReader wkt = new WktReader();
    Geometry g = wkt.read("LINESTRING(-2.0 2.0,0.0 0.0)");
    LineString ls = (LineString) g;
    Geometry g2 = wkt
        .read("LINESTRING(-1.2533333333333332 1.14,-1.1866666666666665 1.14,-1.1866666666666665 1.2066666666666666,-1.2533333333333332 1.2066666666666666,-1.2533333333333332 1.14)");
    LineString ls2 = (LineString) g2;

    // IntersectionMatrix rt = ComputeImFactory.getInstance().getImComputer(
    // ls2, ls).getIM();
    LineString_LineString l2l = new LineString_LineString(ls, ls2);
    IntersectionMatrix rt = l2l.getIM();
    assertTrue(rt.get(IntersectionMatrix.Inner, IntersectionMatrix.Inner) != IntersectionMatrix.EmptyDim);
  }

  @Test
  public void testGetIM5() {
    WktReader wkt = new WktReader();
    Geometry g = wkt
        .read("LINESTRING(1.0 6.0,5.999998414659173 1.0039816335536662,1.0079632645824341 -3.999993658637697,-3.9999857319385903 0.9880551094385923,1.0 6.0)");
    LineString ls = (LineString) g;
    Geometry g2 = wkt
        .read("LINESTRING(-2.639991350383829 -1.7999950537374092,-1.8399918576928131 -1.7999950537374092,-1.8399918576928131 -0.9999955610463935,-2.639991350383829 -0.9999955610463935,-2.639991350383829 -1.7999950537374092)");
    LineString ls2 = (LineString) g2;

    // IntersectionMatrix rt = ComputeImFactory.getInstance().getImComputer(
    // ls2, ls).getIM();
    LineString_LineString l2l = new LineString_LineString(ls, ls2);
    IntersectionMatrix rt = l2l.getIM();
    assertTrue(rt.get(IntersectionMatrix.Inner, IntersectionMatrix.Inner) != IntersectionMatrix.EmptyDim);
  }
}
TOP

Related Classes of chunmap.model.relate.relateop.LineString_LineStringTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.