Comments (2)
What about something like that ? Ridygo@b50b197
Could be used like this :
scope := session.Scope(types.ID("default"))
params := navitia.PlacesNearbyRequest{
Depth: 2,
Distance: 500,
Types: []string{"stop_area"},
}
coords := types.Coordinates{Latitude: dep.Coordinates[1].(float64), Longitude: dep.Coordinates[0].(float64)}
ctx := context.Background()
// Get stop areas near the departure point
res, err := scope.PlacesNearby(ctx, coords, params)
// fmt.Println(res)
if err != nil {
fmt.Println(err)
fmt.Println(res)
}
for _, place := range scope.RelatedContainers(res.Places) {
opts := navitia.ExploreRequest{
// ODTLevel: "scheduled",
}
// get lines in this stop area
// lines, err2 := scope.ExploreResource(ctx, place.ID, "lines", opts)
lines2, err3 := place.Explore(ctx, "lines", opts)
fmt.Println("LINES :")
fmt.Println(lines2)
fmt.Println(err3)
}
(it's a little bit messy right now and needs to be implemented on more types than just Containers)
from navitia.
I like this general direction, though I have a few questions:
On Results
So Results
is a type holding common info for a future request, is that right ? In that case it might be better to name it Proposal
or something like this.
Superficial note: a Scope
already contains a *Session
, no need to store both, and in case where both could be used, it is best to use Scope
.
A question: is the separation between SingleValueResults
and MultiValuesResults
necessary ?
On RelatedContainer
Regarding the RelatedContainers
: if I understand correctly this returns a slice of Results
which then allows you to call Explore
on each result. I like this concept very much, though as you say it needs to be cleaned up still.
On MultiValueResults.Explore
That, I don't understand what you're intending to do. My first impression is, as some XXXResults
types can lead to different requests (for example Regions
), then we need to be able to explore further per dataset for example, or per disruption. Is that what you're trying to solve ?
The way forward ?
First off, thanks for the input, that's certainly a better way to go about it than the proposed solution in the original post, which either requires the library to have a To{Type}
method on results to work easily, or require the user to type-assert, which is bad.
Until your response, I'll see if I can think up something in the same vision as your proposal.
Thanks !
from navitia.
Related Issues (19)
- Add Route Schedules [/route_schedules]
- Add Stop Schedules [/stop_schedules] HOT 1
- Add Traffic Reports [/traffic_reports]
- Add Contributors [/contributors]
- Add Datasets [/datasets]
- Add Isochrones [/isochrones]
- Improve the provider selection.
- Improve handling for remote error parsing failures.
- types: Add validation to all types
- types: Rename all reference to API types to something clearer.
- Add fuzz testing for all methods and functions accepting outside data
- Add VehicleJourney support, both in Explore and in the types subpackage
- types: merge *_json files with regular files
- Datetimes issues (UTC vs local time) HOT 2
- types: VehiclesJourneysResult can't be marshalled in JSON directly
- types: `PhysicalModes` and `GeoJSON` of Route struct seems to be not unmarshalled by Unmarshaller
- CO2Emissions in journeys are not unmarshalled
- Add proto files for types
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from navitia.