Package org.geotools.geometry

Examples of org.geotools.geometry.DirectPosition1D


            } catch (FactoryException e) {
                throw new RuntimeException("Unable to decode SRS name. Cause: " + e.getMessage());
            }
            if (parameters.size() == 3) {
                // 1D
                geom = new DirectPosition1D(crs);
            } else {
                // 2D
                geom = new DirectPosition2D(crs);
                geom.setOrdinate(1, parameters.get(3).evaluate(object, Double.class));
            }
            geom.setOrdinate(0, parameters.get(2).evaluate(object, Double.class));
        } else {
            // should only have points, 1 for 1D, 2 for 2D
            if (parameters.size() > 2) {
                throw new IllegalArgumentException(
                        "Too many parameters for toDirectPosition function: "
                                + parameters.toString() + ". " + USAGE);
            }
            if (parameters.size() == 1) {
                // 1D
                geom = new DirectPosition1D();
            } else {
                // 2D
                geom = new DirectPosition2D();
                geom.setOrdinate(1, parameters.get(1).evaluate(object, Double.class));
            }
View Full Code Here


    }catch (UnsupportedOperationException e) {
     
    }
   
    try{
      defaultAdapter.derivative(new DirectPosition1D(0));
      Assert.assertFalse(true);
    }catch (UnsupportedOperationException e) {
     
    }
   
View Full Code Here

    e0 = DefaultPiecewiseTransform1DElement
        .create("zero", NumberRange.create(3, 3), 0.0);
    Assert.assertTrue(e0 instanceof DefaultConstantPiecewiseTransformElement);
    // checks
    Assert.assertEquals(0.0, e0.transform(3),0.0);
    Assert.assertEquals(3, e0.inverse().transform(new DirectPosition1D(0),null).getOrdinate(0),0);
   
   
    transform = new DefaultPiecewiseTransform1D<DefaultPiecewiseTransform1DElement>(new DefaultPiecewiseTransform1DElement[] {e0});

    // checks
View Full Code Here

          .getOrdinate(0), 0.5, 0.0);
      Assert.assertEquals(p0.inverse().transform(
          new GeneralDirectPosition(new double[] { 0.5 }), null)
          .getOrdinate(0), 0.5, 0.0);
      Assert.assertEquals(p0.derivative(1.0), 1.0, 0.0);
      final DirectPosition1D inDP = new DirectPosition1D(0.6);
      final DirectPosition outDP= p0.transform(inDP, null);
      Assert.assertTrue(outDP.getOrdinate(0)==0.6);
      try{
   
        p0.transform(new double[]{0.5},0,(double[])null,0,0);
        Assert.assertFalse(true);
      }
      catch (UnsupportedOperationException e) {
        // TODO: handle exception
      }
     
      try{
   
        p0.transform(new float[]{0.5f},0,(float[])null,0,0);
        Assert.assertFalse(true);
      }
      catch (UnsupportedOperationException e) {
        // TODO: handle exception
      }
     
     
      try{
        p0.toWKT();
        Assert.assertFalse(true);
      }
      catch (UnsupportedOperationException e) {
        // TODO: handle exception
      }
      Matrix m= p0.derivative(inDP);
      Assert.assertTrue(m.getNumCol()==1);
      Assert.assertTrue(m.getNumRow()==1);
      Assert.assertTrue(m.getElement(0, 0)==1);
     
      ////
      //
      //testing the transform
      //
      ////
      final DefaultPiecewiseTransform1D<DefaultPiecewiseTransform1DElement> piecewise =
          new DefaultPiecewiseTransform1D<DefaultPiecewiseTransform1DElement>(new DefaultPiecewiseTransform1DElement[] { p0 },11);
   
      Assert.assertEquals(piecewise.getApproximateDomainRange().getMinimum(), 0.0, 0.0);
      Assert.assertEquals(piecewise.getApproximateDomainRange().getMaximum(), 1.0, 0.0);
      Assert.assertEquals(piecewise.transform(0.5), 0.5, 0.0);
      Assert.assertEquals(piecewise.transform(
          new GeneralDirectPosition(new double[] { 0.5 }), null)
          .getOrdinate(0), 0.5, 0.0);
      Assert.assertEquals(piecewise.transform(1.5), 0.0, 11.0);
     
      try{
   
        piecewise.transform(new double[]{0.5},0,(double[])null,0,0);
        Assert.assertFalse(true);
      }
      catch (UnsupportedOperationException e) {
        // TODO: handle exception
      }
     
      try{
   
        piecewise.transform(new float[]{0.5f},0,(float[])null,0,0);
        Assert.assertFalse(true);
      }
      catch (UnsupportedOperationException e) {
        // TODO: handle exception
      }
     
     
      try{
        piecewise.toWKT();
        Assert.assertFalse(true);
      }
      catch (UnsupportedOperationException e) {
        // TODO: handle exception
      }
     
      try{
        m= piecewise.derivative(inDP);
        Assert.assertFalse(true);
      }
      catch (UnsupportedOperationException e) {
        // TODO: handle exception
      }
     
      ////
      //
      //testing the passthrough through indirect instantion
      //
      ////
      final DefaultPassthroughPiecewiseTransform1DElement p1 = new DefaultPassthroughPiecewiseTransform1DElement(
          "p1");
      Assert.assertEquals(p1.getTargetDimensions(), 1);
      Assert.assertEquals(p1.getSourceDimensions(), 1);
      Assert.assertTrue(p1.isIdentity());
      Assert.assertEquals(p1.inverse(), LinearTransform1D.IDENTITY);
      Assert.assertEquals(p1.transform(0.5), 0.5, 0.0);
      Assert.assertEquals(p1.transform(111.5), 111.5, 0.0);
      Assert.assertEquals(p1.transform(
          new GeneralDirectPosition(new double[] { 123.5 }), null)
          .getOrdinate(0), 123.5, 0.0);
      Assert.assertEquals(p1.inverse().transform(
          new GeneralDirectPosition(new double[] { 657.5 }), null)
          .getOrdinate(0), 657.5, 0.0);
      Assert.assertEquals(p1.derivative(1.0), 1.0, 0.0);
      final DirectPosition1D inDP1 = new DirectPosition1D(0.6);
      final DirectPosition outDP1= p1.transform(inDP1, null);
      Assert.assertTrue(outDP1.getOrdinate(0)==0.6);
      try{
   
        p1.transform(new double[]{1233444.5},0,(double[])null,0,0);
View Full Code Here

    /**
     * Gets the derivative of this function at a value.
     */
    public double derivative(final double value) throws TransformException {
        final DirectPosition1D p = new DirectPosition1D(value);
        final Matrix m = derivative(p);
        assert m.getNumRow()==1 && m.getNumCol()==1;
        return m.getElement(0,0);
    }
View Full Code Here

        DirectPosition[] dps = new DirectPosition[coordCount];

        if (dim == 1) {
            for (int i = 0; i < coordCount; i++) {
                dps[i] = new DirectPosition1D(crs);
                dps[i].setOrdinate(0, values[i].doubleValue());
            }
        } else if(dim == 2){
            int ordinateIdx = 0;
            // HACK: not sure if its correct to assign ordinates 0 to 0 and 1 to
View Full Code Here

        //double[] position = (double[]) value;
        Double[] position = (Double[]) value;
        DirectPosition dp = null;

        if (position.length < 2) {
            dp = (crs != null) ? new DirectPosition1D(crs) : new DirectPosition1D();
            dp.setOrdinate(0, position[0].doubleValue());
        } else if (position.length < 3 ){
            dp = (crs != null) ? new DirectPosition2D(crs) : new DirectPosition2D();
            dp.setOrdinate(0, position[0].doubleValue());
            dp.setOrdinate(1, position[1].doubleValue());
View Full Code Here

        final ParameterValueGroup parameters = factory.getDefaultParameters(classification);
        parameters.parameter("base").setValue(base);
        final MathTransform1D direct =
             (MathTransform1D) factory.createParameterizedTransform(parameters);
        final MathTransform1D inverse = direct.inverse();
        final DirectPosition1D point = new DirectPosition1D();
        for (int i=0; i<expected.length; i++) {
            final double x = input[i];
            final double y = direct.transform(x);
            assertEquals("transform[x="+x+']', expected[i], y,          1E-6);
            assertEquals("inverse  [y="+y+']', x, inverse.transform(y), 1E-6);
            point.setOrdinate(0, x);
            assertSame(direct.transform(point, point), point);
            assertEquals(y, point.getOrdinate(0), 1E-9);
        }
    }
View Full Code Here

TOP

Related Classes of org.geotools.geometry.DirectPosition1D

Copyright © 2018 www.massapicom. 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.