Package com.vividsolutions.jts.util

Examples of com.vividsolutions.jts.util.Stopwatch


    List circleGrid = createCircleGrid(GRID_SIZE);
   
    PreparedGeometryIndex pgIndex = new PreparedGeometryIndex();
    pgIndex.insert(circleGrid);
   
    Stopwatch sw = new Stopwatch();
    int inCount = runIndexedQuery(pgIndex);
    String indexTime = sw.getTimeString();
   
    System.out.println("Number of iterations       = " + MAX_ITER );
    System.out.println("Number of circles in grid  = " + circleGrid.size() );
    System.out.println();
    System.out.println("The fraction of intersecting points should approximate the total area of the circles:");
    System.out.println();
    System.out.println("Area of circles                = " + area(circleGrid) );
    System.out.println("Fraction of points in circles  = " + inCount / (double) MAX_ITER );
    System.out.println();
    System.out.println("Indexed Execution time: " + indexTime );
   
    /**
     * For comparison purposes run the same query without using an index
     */
    Stopwatch sw2 = new Stopwatch();
    int inCount2 = runBruteForceQuery(circleGrid);
    String bruteForceTime = sw2.getTimeString();
   
    System.out.println();
    System.out.println("Execution time: " + bruteForceTime );

  }
View Full Code Here


    Object result = null;
    if (currentFunc == null || JTSTestBuilder.getGeometryA() == null)
      return null;
   
    try {
      timer = new Stopwatch();
      result = currentFunc.invoke(JTSTestBuilder.getGeometryA(), getFunctionParams());
      timer.stop();
    }
    catch (Exception ex) {
      ex.printStackTrace(System.out);
View Full Code Here

    //queryGrid(200);
  }

  void queryGrid(int nGridCells, double cellSize)
  {
    Stopwatch sw = new Stopwatch();
    sw.start();

    int gridSize = (int) Math.sqrt((double) nGridCells);
    gridSize += 1;
    double extent = MAX_EXTENT - MIN_EXTENT;
    double gridInc = extent / gridSize;

    for (int i = 0; i < gridSize; i++) {
      for (int j = 0; j < gridSize; j++) {
        double x = MIN_EXTENT + gridInc * i;
        double y = MIN_EXTENT + gridInc * j;
        Envelope env = new Envelope(x, x + cellSize,
                                    y, y + cellSize);
        queryTest(env);
        //queryTime(env);
      }
    }
    System.out.println("Time = " + sw.getTimeString());
  }
View Full Code Here

  public IndexResult testAll(List items)
  {
    IndexResult result = new IndexResult(index.toString());
    System.out.print(index.toString() + "           ");
    System.gc();
    Stopwatch sw = new Stopwatch();
    sw.start();
    loadGrid(items);
    String loadTime = sw.getTimeString();
    result.loadMilliseconds = sw.getTime();
    System.gc();
    sw.start();
    //runQueries();
    runSelfQuery(items);
    String queryTime = sw.getTimeString();
    result.queryMilliseconds = sw.getTime();
    System.out.println("  Load Time = " + loadTime + "  Query Time = " + queryTime);
    return result;
  }
View Full Code Here

    }

    @SuppressWarnings("unused")
    private long iterateWithGeometryFactory(SeQuery query, SeQueryInfo seQueryInfo)
            throws SeException {
        Stopwatch sw = new Stopwatch();
        query.prepareQueryInfo(seQueryInfo);
        query.execute();
        try {
            log("- Iterating: " + Arrays.asList(seQueryInfo.getColumns()));
            SeRow row = query.fetch();
            final int ncols = row.getNumColumns();
            final int shapeIdx = ncols - 1;
            Object value;
            Geometry geom;
            int numPoints;
            featureCount = 0;
            totalPoints = 0;
            largerPoints = 0;
            GeometryFactory seGeomFac = new SeToJTSGeometryFactory();
            sw.start();
            while (row != null) {
                featureCount++;
                for (int i = 0; i < ncols; i++) {
                    if (i == shapeIdx) {
                        geom = (Geometry) row.getGeometry(seGeomFac, i);
                        numPoints = geom.getNumPoints();
                        totalPoints += numPoints;
                        largerPoints = Math.max(largerPoints, numPoints);
                    } else {
                        value = row.getObject(i);
                    }
                }
                row = query.fetch();
            }
            sw.stop();
        } finally {
            query.close();
        }
        log("\t- " + featureCount + " features iterated in " + sw.getTimeString());
        log("\t\t- total poinst: " + totalPoints + ", larger geometry: " + largerPoints
                + " points, avg points: " + (totalPoints / featureCount));
        return sw.getTime();
    }
View Full Code Here

        return sw.getTime();
    }

    @SuppressWarnings("unused")
    private long iterate(SimpleFeatureSource fs, Query query) throws IOException {
        Stopwatch sw = new Stopwatch();
        SimpleFeatureCollection features;
        features = fs.getFeatures(query);

        SimpleFeatureIterator iterator;
        iterator = features.features();

        log("- Iterating: " + Arrays.asList(query.getPropertyNames()));
        SimpleFeature feature;
        final int shapeIdx = fs.getSchema().getAttributeCount() - 1;
        try {
            Geometry defaultGeometry;
            featureCount = 0;
            totalPoints = 0;
            int npoints;
            sw.start();
            while (iterator.hasNext()) {
                feature = iterator.next();
                featureCount++;

                defaultGeometry = (Geometry) feature.getDefaultGeometry();
                npoints = defaultGeometry == null ? 0 : defaultGeometry.getNumPoints();
                totalPoints += npoints;
                largerPoints = Math.max(largerPoints, npoints);
            }
            sw.stop();
        } finally {
            iterator.close();
        }
        log("\t- " + featureCount + " features iterated in " + sw.getTimeString());
        log("\t\t- total poinst: " + totalPoints + ", larger geometry: " + largerPoints
                + " points, avg points:" + (totalPoints / featureCount));
        return sw.getTime();
    }
View Full Code Here

        BufferedImage image = new BufferedImage(800, 600, BufferedImage.TYPE_INT_ARGB);
        Graphics2D graphics = image.createGraphics();
        Rectangle paintArea = new Rectangle(800, 600);
        ReferencedEnvelope mapArea = bounds;
        Stopwatch sw = new Stopwatch();
        long totalTime = 0;
        for (int i = 0; i < numRuns; i++) {
            sw.start();
            renderer.paint(graphics, paintArea, mapArea);
            sw.stop();
            totalTime += sw.getTime();
            log("Layer rendered in " + sw.getTimeString());
            sw.reset();
            File output = new File("testRender.png");
            log("writing rendered image to " + output.getAbsolutePath());
            ImageIO.write(image, "png", output);
        }
        log("-- Average rendering time after " + numRuns + " runs: "
View Full Code Here

    }

    @SuppressWarnings("unused")
    private long iterateWithSeShapeFetching(SeQuery query, SeQueryInfo seQueryInfo)
            throws SeException {
        Stopwatch sw = new Stopwatch();
        log("- Executing query " + Arrays.asList(seQueryInfo.getColumns()));
        query.prepareQueryInfo(seQueryInfo);
        query.execute();
        try {
            log("- Iterating: " + Arrays.asList(seQueryInfo.getColumns()));
            SeRow row = query.fetch();
            final int ncols = row.getNumColumns();
            final int shapeIdx = ncols - 1;
            Object value;
            sw.start();
            featureCount = 0;
            totalPoints = 0;
            while (row != null) {
                featureCount++;
                for (int i = 0; i < ncols; i++) {
                    value = row.getObject(i);
                    if (i == shapeIdx) {
                        SeShape shape = (SeShape) value;
                        totalPoints += shape.getNumOfPoints();
                        double[][][] allCoords = shape.getAllCoords();
                        largerPoints = Math.max(largerPoints, shape.getNumOfPoints());
                    }
                }
                row = query.fetch();
            }
            sw.stop();
        } finally {
            query.close();
        }
        log("\t- " + featureCount + " features iterated in " + sw.getTimeString());
        log("\t\t- total poinst: " + totalPoints + ", larger geometry: " + largerPoints + " points"
                + " avg geom points: " + (totalPoints / featureCount));
        return sw.getTime();
    }
View Full Code Here

     */
    private static FeatureCollection<FeatureType, Feature> ccFeatures;

    @BeforeClass
    public static void setUpBeforeClass() throws Exception {
        Stopwatch sw = new Stopwatch();
        sw.start();
        loadDataAccesses();
        sw.stop();
        System.out.println("Set up time: " + sw.getTimeString());
    }
View Full Code Here

        ff = new FilterFactoryImplNamespaceAware(namespaces);
    }

    @BeforeClass
    public static void setUpBeforeClass() throws Exception {
        Stopwatch sw = new Stopwatch();
        sw.start();
        loadDataAccesses();
        sw.stop();
        System.out.println("Set up time: " + sw.getTimeString());
    }
View Full Code Here

TOP

Related Classes of com.vividsolutions.jts.util.Stopwatch

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.