@@ -0,0 +1,2611 @@
+package com.conveyal.r5.analyst;%0A%0Aimport com.conveyal.osmlib.Node;%0Aimport com.conveyal.osmlib.OSM;%0A%0Aimport java.io.FileWriter;%0Aimport java.io.Writer;%0Aimport java.util.Random;%0Aimport java.util.UUID;%0A%0A/**%0A * This is a main method where we can consolidate some example code used to create test fixtures.%0A * In this case, CSV files for testing creation and analysis of freeform pointsets.%0A * The generated CSV is part of the manual full-stack integration tests so is stored outside the Git repo.%0A */%0Apublic class MakeFreeFormTestCSV %7B%0A%0A    public static void main (String%5B%5D args) throws Exception %7B%0A        bikepark();%0A        gaussian();%0A    %7D%0A%0A    public static void gaussian () throws Exception %7B%0A        Writer writer = new FileWriter(%22pdx_gaussian.csv%22);%0A        Random random = new Random();%0A        final double centerLat = 45.5188691;%0A        final double centerLon = -122.6792603;%0A        final double lonRadius = 0.08;%0A        final double latRadius = 0.04;%0A        final int nPoints = 2_000;%0A        writer.write(%22lat,lon,frac,whole,uuid%5Cn%22);%0A        for (int i = 0; i %3C nPoints; i++) %7B%0A            double lat = random.nextGaussian() * latRadius + centerLat;%0A            double lon = random.nextGaussian() * lonRadius + centerLon;%0A            double frac = Math.abs(random.nextGaussian() * 100 + 100);%0A            int whole = random.nextInt(100);%0A            String uuid = UUID.randomUUID().toString().substring(0, 8);%0A            String line = String.format(%22%25f,%25f,%25f,%25d,%25s%5Cn%22, lat, lon, frac, whole, uuid);%0A            writer.write(line);%0A        %7D%0A        writer.close();%0A    %7D%0A%0A    /**%0A     * Extract all points with certain tags from OSM data and export as CSV, adding in some random additional fields to%0A     * test property selection. This can be changed to extract cuisine=coffee_shop or anything else.%0A     */%0A    private static void bikepark () throws Exception %7B%0A        Writer writer = new FileWriter(%22pdx_bikepark.csv%22);%0A        Random random = new Random();%0A        OSM osm = new OSM(null);%0A        osm.readFromFile(%22pdxnodes.pbf%22);%0A        writer.write(%22lat,lon,junk,capacity%5Cn%22);%0A        for (Node node : osm.nodes.values()) %7B%0A            if (node.hasTag(%22amenity%22, %22bicycle_parking%22)) %7B%0A                int capacity = 1;%0A                if (node.hasTag(%22capacity%22)) %7B%0A                    capacity = Integer.parseInt(node.getTag(%22capacity%22).split(%22;%22)%5B0%5D);%0A                %7D%0A                String line = String.format(%22%25f,%25f,%25d,%25d%5Cn%22, node.getLat(), node.getLon(), random.nextInt(), capacity);%0A                writer.write(line);%0A            %7D%0A        %7D%0A        writer.close();%0A    %7D%0A%0A%7D%0A

add utility to generate freeform pointset CSV test fixtures