private void _testCoordinateObjects(PicoContainer c) {
GeometryFactoryImpl cf = (GeometryFactoryImpl) c.getComponentInstanceOfType(GeometryFactory.class);
PrimitiveFactoryImpl tPrimFactory = (PrimitiveFactoryImpl) c.getComponentInstanceOfType( PrimitiveFactoryImpl.class );
PositionFactory positionFactory = (PositionFactory ) c.getComponentInstanceOfType( PositionFactory.class );
// public DirectPositionImpl createDirectPosition();
DirectPosition dp1 = cf.createDirectPosition();
assertTrue(Double.compare(dp1.getOrdinate(0), Double.NaN) == 0);
assertTrue(Double.compare(dp1.getOrdinate(1), Double.NaN) == 0);
assertTrue(Double.compare(dp1.getOrdinate(2), Double.NaN) == 0);
// public DirectPositionImpl createDirectPosition(double[] coord);
double[] da = new double[3];
da[0] = 10.0;
da[1] = -115000.0;
da[2] = 0.0000000125;
DirectPosition dp2 = cf.createDirectPosition(da);
assertTrue(dp2.getOrdinate(0) == 10.0);
assertTrue(dp2.getOrdinate(1) == -115000.0);
assertTrue(dp2.getOrdinate(2) == 0.0000000125);
// public Envelope createEnvelope(
// DirectPosition lowerCorner,
// DirectPosition upperCorner)
Envelope env1 = cf.createEnvelope(dp1, dp2);
DirectPosition lc = env1.getLowerCorner();
assertTrue(Double.compare(lc.getOrdinate(0), Double.NaN) == 0);
assertTrue(Double.compare(lc.getOrdinate(1), Double.NaN) == 0);
assertTrue(Double.compare(lc.getOrdinate(2), Double.NaN) == 0);
DirectPosition uc = env1.getUpperCorner();
assertTrue(uc.getOrdinate(0) == 10.0);
assertTrue(uc.getOrdinate(1) == -115000.0);
assertTrue(uc.getOrdinate(2) == 0.0000000125);
env1 = cf.createEnvelope(dp2, dp1);
lc = env1.getLowerCorner();
assertTrue(lc.getOrdinate(0) == 10.0);
assertTrue(lc.getOrdinate(1) == -115000.0);
assertTrue(lc.getOrdinate(2) == 0.0000000125);
uc = env1.getUpperCorner();
assertTrue(Double.compare(uc.getOrdinate(0), Double.NaN) == 0);
assertTrue(Double.compare(uc.getOrdinate(1), Double.NaN) == 0);
assertTrue(Double.compare(uc.getOrdinate(2), Double.NaN) == 0);
// public Position createPosition(DirectPosition dp);
Position pos1 = cf.createPosition(dp2);
assertTrue(pos1.getDirectPosition().getOrdinate(0) == 10.0);
assertTrue(pos1.getDirectPosition().getOrdinate(1) == -115000.0);
assertTrue(pos1.getDirectPosition().getOrdinate(2) == 0.0000000125);
// public LineSegment createLineSegment(Position startPoint, Position endPoint);
Position pos2 = cf.createPosition(dp1);
LineSegment seg1 = cf.createLineSegment(pos1, pos2);
assertTrue(Double.compare(seg1.getEndPoint().getOrdinate(0), Double.NaN) == 0.0);
assertTrue(Double.compare(seg1.getEndPoint().getOrdinate(1), Double.NaN) == 0.0);
assertTrue(Double.compare(seg1.getEndPoint().getOrdinate(2), Double.NaN) == 0.0);
assertTrue(seg1.getStartPoint().getOrdinate(0) == 10.0);
assertTrue(seg1.getStartPoint().getOrdinate(1) == -115000.0);
assertTrue(seg1.getStartPoint().getOrdinate(2) == 0.0000000125);
// test creating multiprimitive (only creates an empty obj right now)
MultiPrimitive mp = cf.createMultiPrimitive();
assertNotNull(mp);
assertEquals(mp.getCoordinateReferenceSystem(), cf.getCoordinateReferenceSystem());
// test creating polygon
List<DirectPosition> directPositionList = new ArrayList<DirectPosition>();
directPositionList.add(positionFactory.createDirectPosition(new double[] {20, 10, 0.0}));
directPositionList.add(positionFactory.createDirectPosition(new double[] {40, 10, 0.0}));
directPositionList.add(positionFactory.createDirectPosition(new double[] {50, 40, 0.0}));
directPositionList.add(positionFactory.createDirectPosition(new double[] {30, 50, 0.0}));
directPositionList.add(positionFactory.createDirectPosition(new double[] {10, 30, 0.0}));
directPositionList.add(positionFactory.createDirectPosition(new double[] {20, 10, 0.0}));
Ring exteriorRing = tPrimFactory.createRingByDirectPositions(directPositionList);
List<Ring> interiors = new ArrayList<Ring>();
SurfaceBoundary boundary = new SurfaceBoundaryImpl(cf.getCoordinateReferenceSystem(), exteriorRing, interiors);