forked from Project-OSRM/osrm-backend
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
24 changed files
with
515 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Package main contains the tool of chargestation-connectivity generator | ||
// | ||
// stage 1: | ||
// inputs is json file | ||
// => convert to slice of [id:string,location: lat,lon] | ||
// => calculate cellids for each point(for all levels) | ||
// => build revese index for cellID -> ids | ||
// | ||
// stage 2: | ||
// => iterate each point | ||
// => generate a circle(s2::cap), find all cellids intersect with that circle | ||
// => retrieve all ids | ||
// => generate result of id(from), ids(all ids in certain distance) | ||
// | ||
// stage 3: | ||
// => load data from file | ||
// => for each line, its formid and all other ids | ||
// => calculate distance between fromid and all other ids | ||
// => sort result based on distance and write back to file | ||
// | ||
package main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"runtime" | ||
) | ||
|
||
var flags struct { | ||
inputFile string | ||
outputFolder string | ||
numberOfWorkers int | ||
maxRange float64 | ||
osrmBackendEndpoint string | ||
} | ||
|
||
// defaultRange indicates default max drive range in meters. | ||
// This value always bigger than max driven ranges for existing vehicles. | ||
// During query time could just take subset of pre-processed result based on real range. | ||
const defaultMaxRange = 800000 | ||
|
||
func init() { | ||
flag.StringVar(&flags.inputFile, "i", "", "path for input file in json format") | ||
flag.StringVar(&flags.outputFolder, "o", "", "path for output folder") | ||
flag.IntVar(&flags.numberOfWorkers, "num_of_workers", runtime.NumCPU(), "number of workers to build connectivity map") | ||
flag.Float64Var(&flags.maxRange, "range", defaultMaxRange, "maximum drive range in meters used for preprocessing.") | ||
flag.StringVar(&flags.osrmBackendEndpoint, "osrm", "", "OSRM-backend endpoint") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"os" | ||
"time" | ||
|
||
"github.com/Telenav/osrm-backend/integration/oasis/osrmconnector" | ||
"github.com/Telenav/osrm-backend/integration/service/connectivitymap" | ||
"github.com/Telenav/osrm-backend/integration/service/spatialindexer" | ||
"github.com/Telenav/osrm-backend/integration/service/spatialindexer/ranker" | ||
"github.com/Telenav/osrm-backend/integration/service/spatialindexer/s2indexer" | ||
"github.com/golang/glog" | ||
) | ||
|
||
func main() { | ||
flag.Parse() | ||
defer glog.Flush() | ||
startTime := time.Now() | ||
|
||
if flags.inputFile == "" || flags.outputFolder == "" { | ||
glog.Fatal("Empty string for inputFile or outputFolder, please check your input.\n") | ||
} | ||
|
||
var rankerStrategy spatialindexer.Ranker | ||
if flags.osrmBackendEndpoint == "" { | ||
glog.Warning("No information about OSRM Endpoint, can only init ranker with great circle distance.") | ||
rankerStrategy = ranker.CreateRanker(ranker.SimpleRanker, nil) | ||
} else { | ||
rankerStrategy = ranker.CreateRanker(ranker.OSRMBasedRanker, | ||
osrmconnector.NewOSRMConnector(flags.osrmBackendEndpoint)) | ||
} | ||
|
||
indexer := s2indexer.NewS2Indexer().Build(flags.inputFile) | ||
if indexer == nil { | ||
glog.Fatalf("Failed to build indexer, stop %s\n", os.Args[0]) | ||
} | ||
indexer.Dump(flags.outputFolder) | ||
|
||
connectivitymap.NewConnectivityMap(flags.maxRange). | ||
Build(indexer, indexer, rankerStrategy, flags.numberOfWorkers). | ||
Dump(flags.outputFolder) | ||
|
||
glog.Infof("%s totally takes %f seconds for processing.", os.Args[0], time.Since(startTime).Seconds()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.