Package org.opentripplanner.analyst

Examples of org.opentripplanner.analyst.PointSet



      final TimeSurface surf = server.surfaceCache.get(surfaceId);
     
        if (surf == null) return badRequest("Invalid TimeSurface ID.");
        final PointSet pset = server.pointSetCache.get(targetPointSetId);
        if (pset == null) return badRequest("Missing or invalid target PointSet ID.");
       
        //TODO cache this sampleset
        Graph gg = server.graphService.getGraph(surf.routerId);
        SampleSet samples = pset.getSampleSet( gg );
       
        final ResultFeature indicator = new ResultFeature(samples, surf);
        if (indicator == null) return badServer("Could not compute indicator as requested.");
        return Response.ok().entity(new StreamingOutput() {
            @Override
View Full Code Here


import java.util.Map.Entry;

public class PointSetTest extends TestCase {

    public void testPointSets() throws IOException {
        PointSet austin = PointSet.fromCsv(new File("src/test/resources/pointset/austin.csv"));
        assertNotNull(austin);
        assertEquals(austin.capacity, 15922);
    }
View Full Code Here

        assertEquals(austin.capacity, 15922);
    }

    /** Factory method should return null but not throw an exception on malformed CSV. */
    public void testBogusCSV() throws IOException {
        PointSet points = PointSet.fromCsv(new File("src/test/resources/pointset/bogus.csv"));
        assertNull(points);
    }
View Full Code Here

        PointSet points = PointSet.fromCsv(new File("src/test/resources/pointset/bogus.csv"));
        assertNull(points);
    }

    public void testLoadGeoJson() {
        PointSet points = PointSet.fromGeoJson(new File("src/test/resources/pointset/population.geo.json"));
        assertNotNull(points);
        assertEquals(points.capacity, 2);
    }
View Full Code Here

        assertNotNull(points);
        assertEquals(points.capacity, 2);
    }
   
    public void testLoadShapefile() throws NoSuchAuthorityCodeException, IOException, FactoryException, EmptyPolygonException, UnsupportedGeometryException {
        PointSet points = PointSet.fromShapefile(new File("src/test/resources/pointset/shp/austin.shp"));
        assertNotNull(points);
        PointFeature ft = points.getFeature(0);
        int pop = ft.getProperty("DEC_10_S_2");
        assertEquals( pop, 42 );
    }
View Full Code Here

        int pop = ft.getProperty("DEC_10_S_2");
        assertEquals( pop, 42 );
    }
   
    public void testGetFeature() {
        PointSet points = PointSet.fromGeoJson(new File("src/test/resources/pointset/population.geo.json"));
        PointFeature pt = points.getFeature(0);
       
        assertNotNull(pt);
        assertEquals( pt.getId(), "XYZ0001");
        Map<String,Integer> attrs = pt.getProperties();
        assertEquals( attrs.size(), 6 );
View Full Code Here

        assertEquals( attrs.size(), 6 );
        assertEquals( pt.getProperty( "age:child" ), 10 );
    }
   
    public void testSlice() {
      PointSet points = PointSet.fromGeoJson(new File("src/test/resources/pointset/population.geo.json"));
     
      PointSet all = points.slice(0, points.featureCount());
      assertEquals( all.featureCount(), points.featureCount() );
     
      PointSet firstHalf = points.slice(0, 1);
      assertEquals( firstHalf.featureCount(), 1 );
      assertEquals( firstHalf.getFeature(0).getId(), "XYZ0001" );
     
      PointSet lastHalf = points.slice(1, 2);
      assertEquals( lastHalf.featureCount(), 1 );
      assertEquals( lastHalf.getFeature(0).getId(), "XYZ0002" );
    }
View Full Code Here

    @Produces(MediaType.APPLICATION_JSON)
    public Response getPointSet (
        @PathParam("pointSetId") String pointSetId) {
     
     
        final PointSet pset = server.pointSetCache.get(pointSetId);
        if (pset == null) {
            return Response.status(Status.NOT_FOUND).entity("Invalid PointSet ID.").build();
        }
        if (pset.capacity > 200) {
            // too big, just give a summary
            return Response.ok().entity(new PointSetShort(pointSetId, pset)).build();
        }
        return Response.ok().entity(new StreamingOutput() {
            @Override
            public void write(OutputStream output) throws IOException, WebApplicationException {
                pset.writeJson(output);
            }
        }).build();
    }
View Full Code Here

TOP

Related Classes of org.opentripplanner.analyst.PointSet

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.