Package chunmap.model.elem

Source Code of chunmap.model.elem.EnvelopTest

/**
* 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.elem;

import static org.junit.Assert.*;

import org.junit.Test;

import chunmap.model.coord.Coordinate2D;
import chunmap.model.coord.CPoint;
import chunmap.model.elem.Envelope;
import chunmap.model.geom.GeoPoint;

/**
* @author chunquedong
*
*/
public class EnvelopTest {

  /**
   * {@link chunmap.model.elem.Envelope#getCenter()} 的测试方法。
   */
  @Test
  public void testGetCenter() {
    Envelope envelop = new Envelope(10, 16, 20, 22);
    CPoint p = envelop.getCenter();
    CPoint expected = new Coordinate2D(15, 19);
    boolean b = p.equals(expected);
    assertTrue(b);
  }

  @Test
  public void testMergeEnvelop() {
    Envelope envelop1 = new Envelope(10, 16, 20, 22);
    Envelope envelop2 = new Envelope(7, 18, 17, 25);
    // Envelop expected=new Envelop(7,20,16,25);
    EnvelopeBuf env = new EnvelopeBuf();
    env.mergeEnvelop(envelop1);
    env.mergeEnvelop(envelop2);
    envelop1 = env.toEnvelop();

    boolean b1 = (envelop1.getMinX() == 7);
    boolean b2 = (envelop1.getMaxX() == 20);
    boolean b3 = (envelop1.getMinY() == 16);
    boolean b4 = (envelop1.getMaxY() == 25);

    assertTrue(b1 && b2 && b3 && b4);
  }

  @Test
  public void testContain() {
    Envelope envelop1 = new Envelope(10, 16, 20, 22);
    CPoint p = new Coordinate2D(11, 17);

    boolean b1 = envelop1.contain(p);
    assertTrue(b1);
  }

  @Test
  public void testContain2() {
    Envelope envelop1 = new Envelope(10, 16, 10, 16);
    CPoint p = new Coordinate2D(10, 16);

    boolean b1 = envelop1.contain(p);
    assertTrue(b1);
  }

  @Test
  public void testContain3() {
    CPoint p = new Coordinate2D(10, 16);
    Envelope envelop1 = new GeoPoint(p).getEnvelop();
    boolean b1 = envelop1.contain(p);
    assertTrue(b1);
  }

}
TOP

Related Classes of chunmap.model.elem.EnvelopTest

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.