Package org.geotools.geometry

Examples of org.geotools.geometry.DirectPosition2D


        final Random random = new Random(8578348921369L);

        for (int i = 0; i < number; i++) {
            double x = minx + (random.nextDouble() * (maxx - minx));
            double y = miny + (random.nextDouble() * (maxy - miny));
            positions.put(new DirectPosition2D(env.getCoordinateReferenceSystem(), x, y),
                random.nextDouble() * approxValue);
        }

        return positions;
    }
View Full Code Here


    public static void main2(String[] args) {
        try {
            // Prepare Coordinate System and Evelope
            CoordinateReferenceSystem crs = DefaultEngineeringCRS.CARTESIAN_2D;

            DirectPosition minDp = new DirectPosition2D(crs, 10.0, 10.0);
            DirectPosition maxDp = new DirectPosition2D(crs, 1000.0, 1000.0);

            Envelope env = new GeneralEnvelope(new GeneralDirectPosition(minDp),
                    new GeneralDirectPosition(maxDp));

            // Lets Generate some known points that will define interpolation
            HashMap /*<DirectPosition2D, Float>*/ pointsAndValues = new HashMap();

            pointsAndValues.put(new DirectPosition2D(crs, 130, 805), 6.5);
            pointsAndValues.put(new DirectPosition2D(crs, 14, 105), 1.5);
            pointsAndValues.put(new DirectPosition2D(crs, 45, 78), -9.5);
            pointsAndValues.put(new DirectPosition2D(crs, 905, 28), 7.5);
            pointsAndValues.put(new DirectPosition2D(crs, 123, 185), 16.5);
            pointsAndValues.put(new DirectPosition2D(crs, 104, 215), -21.5);
            pointsAndValues.put(new DirectPosition2D(crs, 45, 708), -9.5);
            pointsAndValues.put(new DirectPosition2D(crs, 905, 350), 17.5);
            pointsAndValues.put(new DirectPosition2D(crs, 905, 850), -45.5);

            //now we can construct the Interpolation Object 
            TPSInterpolation interpolation = new TPSInterpolation(pointsAndValues, 2, 2, env);

            // we can get and show coverage
            (new GridCoverageFactory()).create("Intepolated Coverage", interpolation.get2DGrid(),
                env).show();

            // or we can interpolate value in any DirectPosition
            System.out.print(interpolation.getValue(new DirectPosition2D(12.34, 15.123)));

            /* AbstractInterpolation interpoaltion = new TPSInterpolation(
               generatePositionsWithValues(env,15, 5),
               env.getLength(0)/500,
               env.getLength(1)/500,
View Full Code Here

    for (Iterator<MappedPosition> i = MappedPositions.iterator(); i
        .hasNext();) {
      MappedPosition mp = (MappedPosition) i.next();

      DirectPosition2D gridSource = new DirectPosition2D();
      DirectPosition2D gridTarget = new DirectPosition2D();
      trans.transform(mp.getSource(), gridSource);
      gridSource
          .setCoordinateReferenceSystem(DefaultEngineeringCRS.CARTESIAN_2D);

      trans.transform(mp.getTarget(), gridTarget);
      gridTarget
          .setCoordinateReferenceSystem(DefaultEngineeringCRS.CARTESIAN_2D);

      gridmp.add(new MappedPosition(gridSource, gridTarget));
    }
View Full Code Here

      throws TransformException {
    float[] warpPositions = (float[]) gridParams.getWarpPositions();// .parameter("warpPositions").getValue();

    for (int i = 0; i <= gridParams.getYNumber(); i++) {
      for (int j = 0; j <= gridParams.getXNumber(); j++) {
        DirectPosition2D dp = new DirectPosition2D(gridParams
            .getXStart()
            + (j * gridParams.getXStep()), gridParams.getYStart()
            + (i * gridParams.getYStep()));

        double x = -dxInterp.getValue(dp) + (j * gridParams.getXStep())
 
View Full Code Here

      GridCoverageFactory fac = new GridCoverageFactory();
       GridCoverage2D cov = fac.create("sd", g, env);
      
     
      // Generate some known points to root the interpolation
      DirectPosition a = new DirectPosition2D(crs,10,10);
      DirectPosition b = new DirectPosition2D(crs,80,80);
      DirectPosition c = new DirectPosition2D(crs,10,90);
      DirectPosition d = new DirectPosition2D(crs,80,10);

     
      // Define at each point the values to be interpolated; we do this in a HashMap
      Map<DirectPosition, Float> pointsAndValues = new HashMap();
      pointsAndValues.put(a,  new Float(6.5456));
View Full Code Here

      builder.setMappedPositions(mps);
     
    //  MathTransform trans = (new TPSGridBuilder(mps,0.01, 0.01, builder.getEnvelope(), builder.getWorldToGrid().inverse())).getMathTransform();
      MathTransform trans = builder.getMathTransform();
      //System.out.println(builder.getMappedPositions().size());
      DirectPosition dst = new DirectPosition2D();
      m=m+(mapPos.getError(trans, null));
      System.out.println((mapPos.getError(trans, null)));//*Math.PI/180 * 6480000);
      //System.out.println(trans.transform(mapPos.getSource(), null));
      //System.out.println("transformed - "+dst);
      //System.out.println("Should be - "+map.getTarget());
View Full Code Here

        final Random random = new Random(8578348921369L);

        for (int i = 0; i < number; i++) {
            double x = minx + (random.nextDouble() * (maxx - minx));
            double y = miny + (random.nextDouble() * (maxy - miny));
            vectors.add(new MappedPosition(new DirectPosition2D(crs, x, y),
                    new DirectPosition2D(crs,
                        (x + (random.nextDouble() * deltas)) - (random.nextDouble() * deltas),
                        (y + (random.nextDouble() * deltas)) - (random.nextDouble() * deltas))));
        }

        return vectors;
View Full Code Here

    public static void gridTest(List<MappedPosition> mps, MathTransform trans) throws TransformException{
    double sum = 0;
    int j = 0;
    for(Iterator<MappedPosition> i = mps.iterator(); i.hasNext();){
      MappedPosition mp = i.next();
      DirectPosition2D test = new DirectPosition2D(0,0);
      trans.transform(mp.getSource(),test);
     
      Assert.assertEquals(mp.getTarget().getOrdinate(0), test.getOrdinate(0), 0.04);
      Assert.assertEquals(mp.getTarget().getOrdinate(1), test.getOrdinate(1), 0.04);
       double dx =  Math.pow((mp.getTarget().getOrdinate(0)-test.getOrdinate(0)),2);
       double dy =  Math.pow((mp.getTarget().getOrdinate(1)-test.getOrdinate(1)),2);
       
       sum = sum + Math.pow((dx+dy),0.5);
       
     
          j++;
View Full Code Here

// click1 end

// distance start
SimpleFeatureCollection distance(MapMouseEvent ev) throws Exception {
    DirectPosition2D worldPosition = ev.getMapPosition();
   
    // get the unit of measurement
    SimpleFeatureType schema = featureSource.getSchema();
    CoordinateReferenceSystem crs = schema.getGeometryDescriptor().getCoordinateReferenceSystem();
    Unit<?> uom = crs.getCoordinateSystem().getAxis(0).getUnit();
   
    MathTransform transform = CRS.findMathTransform(worldPosition.getCoordinateReferenceSystem(),
            crs, true);
   
    DirectPosition dataPosition = transform.transform(worldPosition, null);
   
    Point point = JTS.toGeometry(dataPosition);
View Full Code Here

        public void onMouseClicked(MapMouseEvent ev) {
            // print the screen and world position of the mouse
            System.out.println("mouse click at");
            System.out.printf("  screen: x=%d y=%d \n", ev.getX(), ev.getY());

            DirectPosition2D pos = ev.getWorldPos();
            System.out.printf("  world: x=%.2f y=%.2f \n", pos.x, pos.y);
        }

        @Override
        public void onMouseEntered(MapMouseEvent ev) {
View Full Code Here

TOP

Related Classes of org.geotools.geometry.DirectPosition2D

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.