Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Dev brach to bring new developments to master #175

Merged
merged 95 commits into from
Jul 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
945d735
Added R5's isochrone feature to r5r
mvpsaraiva Apr 22, 2021
a290732
Added R5's isochrone feature to r5r
mvpsaraiva Apr 22, 2021
02a4f7e
Added support for elevation weighting of street edges.
mvpsaraiva Apr 27, 2021
5716d1a
Merge branch 'isochrone' into dev
mvpsaraiva Apr 27, 2021
9653550
Deleting merge conflicts
mvpsaraiva Apr 27, 2021
4e27f40
Changed java build configuration
mvpsaraiva Apr 27, 2021
6b2502a
Working on isochrones function (R and Java)
mvpsaraiva Apr 28, 2021
b101190
Load elevation data when a DEM file in .tif format is found in the da…
mvpsaraiva Apr 28, 2021
a260832
Fixed elevation utils and isochrone function
mvpsaraiva Apr 28, 2021
9a97d5c
Elevation and isochrone functions maintenance and documentation
mvpsaraiva Apr 28, 2021
f0a1a16
Fixed conversion of travel times from minutes to seconds in Isochrones
mvpsaraiva Apr 28, 2021
84b6456
Updated r5r Jar to version 0.5-0
mvpsaraiva Apr 29, 2021
91e3beb
Improving detailed_itineraries
mvpsaraiva May 3, 2021
c303f44
Updating calculation of transfer times between transit stops
mvpsaraiva May 4, 2021
0e788f0
Merge branch 'master' into dev
mvpsaraiva May 4, 2021
033d47e
Initial refactoring (not working)
mvpsaraiva May 4, 2021
559a558
Added dependency to purrr package
mvpsaraiva May 5, 2021
a002b35
Setting verbose = FALSE in test-detailed_itineraries (reverting back …
mvpsaraiva May 5, 2021
2d04048
Created Utils class with static methods, to streamline R5RCore class
mvpsaraiva May 5, 2021
d867f76
Refactoring: moving excess code from R5RCore to other classes
mvpsaraiva May 5, 2021
83b818e
Refactoring: moving excess code from R5RCore to other classes
mvpsaraiva May 5, 2021
8effc16
Refactoring: function to create RegionalTask
mvpsaraiva May 5, 2021
2e67037
Refactoring: function to create RegionalTaskRefactoring: moving exces…
mvpsaraiva May 5, 2021
d3c33ff
Refactoring: function to create RegionalTaskRefactoring: moving exces…
mvpsaraiva May 5, 2021
9a4c353
Refactoring: function to create RegionalTaskRefactoring: moving exces…
mvpsaraiva May 5, 2021
4501410
Refactoring: function to create RegionalTaskRefactoring: moving exces…
mvpsaraiva May 5, 2021
6fefe45
Code cleanup
mvpsaraiva May 5, 2021
7e4e5a0
Refactoring: function to create RegionalTaskRefactoring: moving exces…
mvpsaraiva May 5, 2021
9100968
Refactoring: function to create RegionalTaskRefactoring: moving exces…
mvpsaraiva May 5, 2021
b750c0d
Refactoring: function to create RegionalTaskRefactoring: moving exces…
mvpsaraiva May 6, 2021
d24f27d
Refactoring: function to create RegionalTaskRefactoring: moving exces…
mvpsaraiva May 6, 2021
f6102fb
Refactoring: function to create RegionalTaskRefactoring: moving exces…
mvpsaraiva May 6, 2021
491a2d9
Refactoring: function to create RegionalTaskRefactoring: moving exces…
mvpsaraiva May 6, 2021
6a84471
Code cleanup
mvpsaraiva May 6, 2021
c396cba
Code cleanup
mvpsaraiva May 6, 2021
5b6cab4
Added SnapFinder feature to Java core, to verify results of R5 snappi…
mvpsaraiva May 6, 2021
a6074e8
Improvements in SnapFinder
mvpsaraiva May 7, 2021
1731595
Added snap_distance and search_radius to the results of SnapFinder
mvpsaraiva May 7, 2021
d554e63
Removed board_time and alight_time from detailed itineraries due to s…
mvpsaraiva May 7, 2021
051f43b
Refactoring and code cleanup of TravelTimeMatrixComputer
mvpsaraiva May 7, 2021
3396c8d
Merge pull request #166 from ipeaGIT/r5r_java_refactoring
mvpsaraiva May 7, 2021
2a4e0f0
updated r5r_jar
mvpsaraiva May 7, 2021
197d1ec
Updated R5RCore isochrone function to account for missing input case:…
mvpsaraiva May 7, 2021
60f3ef6
Code cleanup
mvpsaraiva May 7, 2021
f969f48
updated gitignore
mvpsaraiva May 10, 2021
544e9aa
Updated jar
mvpsaraiva May 10, 2021
0e6ae49
Modified getSnapPoints function to call R5's findSplit function directly
mvpsaraiva May 11, 2021
8630842
Modified test_snap
mvpsaraiva May 11, 2021
04c44e7
Modified test_snap
mvpsaraiva May 12, 2021
992572f
Added AccessibilityEstimator to r5r core
mvpsaraiva May 13, 2021
80e5168
New accessibility estimation feature
mvpsaraiva May 13, 2021
5039412
Updated documentation
mvpsaraiva May 13, 2021
f3bf219
Updated AccessibilityEstimator, with added support for decay functions.
mvpsaraiva May 14, 2021
025559b
`getGrid()` function now returns each cell's geometry alongside it's …
mvpsaraiva May 14, 2021
9fc9274
Removed dependency on `%>%` from `setup_r5`
mvpsaraiva May 14, 2021
beb25c2
`getGrid()` function now returns each cell's geometry alongside it's …
mvpsaraiva May 14, 2021
ba0816f
Modified the StreetNetwork class, used by `street_network_to_sf()`, t…
mvpsaraiva May 17, 2021
6e33463
Update documentation
mvpsaraiva May 18, 2021
075002a
Updated `assert_points()` function to accept:
mvpsaraiva May 18, 2021
0cbc443
Added `find_snap()` R wrapper function around Java's `findSnapPoints()`
mvpsaraiva May 21, 2021
9cf1d98
Removed `n_threads` parameter from `find_snap()`.
mvpsaraiva May 21, 2021
027f578
Removed `isochrones()` function
mvpsaraiva May 21, 2021
96d36ca
Reverted changes to `assert_points_input()`
mvpsaraiva May 21, 2021
a184f03
Fixed data.table call in `find_snap()`
mvpsaraiva May 21, 2021
e88f712
Documents and tests find_snap() fun. Closes #168
rafapereirabr May 24, 2021
ac743b5
update documentation
rafapereirabr May 24, 2021
b5090b4
Added check for `opportunities_column` name and value in `accessibili…
mvpsaraiva May 27, 2021
370cf64
Updated documentation of `accessibility()` function
mvpsaraiva May 27, 2021
89598e8
Cleaned tests_marcus folder
mvpsaraiva May 27, 2021
965fa2d
Update documentation
mvpsaraiva May 27, 2021
2ae36c5
Added simple implementation of a progress indicator, activated when `…
mvpsaraiva May 27, 2021
3293558
Added `get()` back to selection of opportunities column in accessibil…
mvpsaraiva May 27, 2021
71dbb29
Updated progress bar message.
mvpsaraiva May 27, 2021
2d43d47
Fixed verbose mode in `detailed_itineraries()`
mvpsaraiva May 27, 2021
603bd4c
Removed `get()` from data.table col when accessing `opportunities_col…
mvpsaraiva Jun 28, 2021
4cf07b0
Changed syntax for accessing `opportunities_colname` from data.table
mvpsaraiva Jun 28, 2021
5a5a1b6
test accessibility
rafapereirabr Jun 28, 2021
09e4587
add test-accessibility.R
rafapereirabr Jun 28, 2021
0d79062
Added `max_bike_dist` to `travel_time_matrix`, `detailed_itineraries`…
mvpsaraiva Jun 29, 2021
10c72b0
Updated documentation
mvpsaraiva Jun 29, 2021
6131201
Merge branch 'dev' of https://github.com/ipeaGIT/r5r into dev
mvpsaraiva Jun 29, 2021
2135e36
Updated documentation
mvpsaraiva Jun 29, 2021
4c54902
Added `max_bike_dist` parameter to `accessibility()`, `travel_time_ma…
mvpsaraiva Jun 29, 2021
00ddc7b
update NEWS. Add new max_bike_dist Closes #174
rafapereirabr Jul 1, 2021
fd2cf1b
test elevation_utils.R
rafapereirabr Jul 1, 2021
972e38c
improve coverage of setup_r5
rafapereirabr Jul 1, 2021
1e351f5
Closes #169. Closes 169
rafapereirabr Jul 1, 2021
c8d8e52
fix elevation test
rafapereirabr Jul 1, 2021
a4fd189
fix typo
rafapereirabr Jul 1, 2021
27787ef
reduced the size of poa's gtfs file
dhersz Jul 1, 2021
c85ce5f
Merge remote-tracking branch 'origin/dev' into dev
dhersz Jul 1, 2021
8a64097
run checks on dev as well
dhersz Jul 1, 2021
773cce7
imports raster
dhersz Jul 1, 2021
f6f4e80
add rgdal as a "suggests" dependency
dhersz Jul 1, 2021
d7653a2
removed redundant raster dependency lol
dhersz Jul 1, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ on:
branches:
- main
- master
- dev
pull_request:
branches:
- main
- master
- dev

name: R-CMD-check

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ java-r5rcore/out/production/r5r/org/ipea/r5r/TravelTimeMatrixComputer.class
java-r5rcore/out
java-r5rcore/libs
.DS_Store
java-r5rcore/target
8 changes: 8 additions & 0 deletions java-r5rcore/.idea/artifacts/r5r_0_5_0_jar.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions java-r5rcore/.idea/artifacts/r5r_jar.xml

This file was deleted.

124 changes: 124 additions & 0 deletions java-r5rcore/.idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

164 changes: 164 additions & 0 deletions java-r5rcore/src/org/ipea/r5r/AccessibilityEstimator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
package org.ipea.r5r;

import com.conveyal.r5.OneOriginResult;
import com.conveyal.r5.analyst.FreeFormPointSet;
import com.conveyal.r5.analyst.PointSet;
import com.conveyal.r5.analyst.TravelTimeComputer;
import com.conveyal.r5.analyst.cluster.RegionalTask;
import com.conveyal.r5.analyst.decay.*;
import com.conveyal.r5.api.util.LegMode;
import com.conveyal.r5.profile.StreetMode;
import com.conveyal.r5.transit.TransportNetwork;
import org.slf4j.LoggerFactory;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;

public class AccessibilityEstimator extends R5MultiDestinationProcess {

private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(AccessibilityEstimator.class);

private FreeFormPointSet destinationPoints;
private DecayFunction decayFunction;

public void setDecayFunction(String decayFunction, double decayValue) {
decayFunction = decayFunction.toUpperCase();
if (decayFunction.equals("STEP")) { this.decayFunction = new StepDecayFunction(); }
if (decayFunction.equals("EXPONENTIAL")) { this.decayFunction = new ExponentialDecayFunction(); }

if (decayFunction.equals("FIXED_EXPONENTIAL")) {
this.decayFunction = new FixedExponentialDecayFunction();
((FixedExponentialDecayFunction) this.decayFunction).decayConstant = decayValue;
}
if (decayFunction.equals("LINEAR")) {
this.decayFunction = new LinearDecayFunction();
((LinearDecayFunction) this.decayFunction).widthMinutes = (int) decayValue;
}
if (decayFunction.equals("LOGISTIC")) {
this.decayFunction = new LogisticDecayFunction();
((LogisticDecayFunction) this.decayFunction).standardDeviationMinutes = decayValue;
}
this.decayFunction.prepare();
}

public AccessibilityEstimator(ForkJoinPool threadPool, TransportNetwork transportNetwork, RoutingProperties routingProperties) {
super(threadPool, transportNetwork, routingProperties);
destinationPoints = null;
}

@Override
public List<LinkedHashMap<String, ArrayList<Object>>> run() throws ExecutionException, InterruptedException {
buildDestinationPointSet();
return super.run();
}

private void buildDestinationPointSet() {
ByteArrayOutputStream dataStream = new ByteArrayOutputStream();
DataOutputStream pointStream = new DataOutputStream(dataStream);

try {
pointStream.writeInt(toIds.length);
for (String toId : toIds) {
pointStream.writeUTF(toId);
}
for (double toLat : toLats) {
pointStream.writeDouble(toLat);
}
for (double toLon : toLons) {
pointStream.writeDouble(toLon);
}
for (int opportunity : opportunities) {
pointStream.writeDouble(opportunity);
}
} catch (IOException e) {
e.printStackTrace();
}

ByteArrayInputStream pointsInput = new ByteArrayInputStream(dataStream.toByteArray());

try {
destinationPoints = new FreeFormPointSet(pointsInput);
} catch (IOException e) {
e.printStackTrace();
}

if (!this.directModes.isEmpty()) {
for (LegMode mode : this.directModes) {
transportNetwork.linkageCache.getLinkage(destinationPoints, transportNetwork.streetLayer, StreetMode.valueOf(mode.toString()));
}
}
}

@Override
protected LinkedHashMap<String, ArrayList<Object>> runProcess(int index) throws ParseException {
RegionalTask request = buildRequest(index);

TravelTimeComputer computer = new TravelTimeComputer(request, transportNetwork);
OneOriginResult travelTimeResults = computer.computeTravelTimes();
RDataFrame travelTimesTable = buildDataFrameStructure(fromIds[index]);
populateDataFrame(travelTimeResults, travelTimesTable);

if (travelTimesTable.nRow() > 0) {
return travelTimesTable.getDataFrame();
} else {
return null;
}
}

private void populateDataFrame(OneOriginResult travelTimeResults, RDataFrame travelTimesTable) {
int[][][] accessibility = travelTimeResults.accessibility.getIntValues();

int nPercentiles = routingProperties.percentiles.length;
int nCutoffs = routingProperties.cutoffs.length;


for (int p = 0; p < nPercentiles; p++) {
for (int c = 0; c < nCutoffs; c++) {
travelTimesTable.append();
travelTimesTable.set("percentile", routingProperties.percentiles[p]);
travelTimesTable.set("cutoff", routingProperties.cutoffs[c]);
travelTimesTable.set("accessibility", accessibility[0][p][c]);
}
}
}

private RDataFrame buildDataFrameStructure(String fromId) {
// Build return table
RDataFrame travelTimesTable = new RDataFrame();
travelTimesTable.addStringColumn("from_id", fromId);
travelTimesTable.addIntegerColumn("percentile", 0);
travelTimesTable.addIntegerColumn("cutoff", 0);
travelTimesTable.addIntegerColumn("accessibility", 0);

return travelTimesTable;
}

@Override
protected RegionalTask buildRequest(int index) throws ParseException {
RegionalTask request = super.buildRequest(index);

request.destinationPointSetKeys = new String[1];
request.destinationPointSetKeys[0] = "opportunities";
request.destinationPointSets = new PointSet[1];
request.destinationPointSets[0] = destinationPoints;

request.percentiles = this.routingProperties.percentiles;
request.recordAccessibility = true;
request.recordTimes = false;
request.includePathResults = false;
request.decayFunction = this.decayFunction;

request.cutoffsMinutes = routingProperties.cutoffs;

return request;
}

}
Loading