Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Routing Service
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWP Datenverwaltung Navigation 2023
Routing Service
Merge requests
!12
Roadnetwork map matching
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Roadnetwork map matching
roadnetwork_map_matching
into
main
Overview
0
Commits
2
Pipelines
0
Changes
12
Merged
lazarog98
requested to merge
roadnetwork_map_matching
into
main
2 years ago
Overview
0
Commits
2
Pipelines
0
Changes
12
Expand
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
87c247f6
2 commits,
2 years ago
12 files
+
323
−
224
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
12
Search (e.g. *.vue) (Ctrl+P)
routing-server/src/main/java/de/fuberlin/navigator/routingserver/controller/RoutingController.java
+
86
−
86
Options
package
de.fuberlin.navigator.routingserver.controller
;
package
de.fuberlin.navigator.routingserver.controller
;
import
java.io.IOException
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.node.ArrayNode
;
import
com.fasterxml.jackson.databind.node.ArrayNode
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
de.fuberlin.navigator.protos.map_builder.Coordinates
;
import
de.fuberlin.navigator.routingserver.model.AdressRequest
;
import
de.fuberlin.navigator.routingserver.model.AdressRequest
;
import
de.fuberlin.navigator.routingserver.model.
Coordinates
;
import
de.fuberlin.navigator.routingserver.model.
Point
;
import
de.fuberlin.navigator.routingserver.model.RoutingRequest
;
import
de.fuberlin.navigator.routingserver.model.RoutingRequest
;
import
de.fuberlin.navigator.routingserver.utility.ApplyShortestPath
;
import
de.fuberlin.navigator.routingserver.utility.ApplyShortestPath
;
import
de.fuberlin.navigator.routingserver.utility.MapMatcher
;
import
de.fuberlin.navigator.routingserver.utility.MapMatcher
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.bind.annotation.*
;
import
java.io.IOException
;
import
java.util.List
;
@RestController
@RestController
public
class
RoutingController
{
public
class
RoutingController
{
@Autowired
@Autowired
private
ObjectMapper
mapper
;
private
ObjectMapper
mapper
;
/**
/**
* Method is a dummy for now. Answers with a list of coordinates, where each
* Method is a dummy for now. Answers with a list of coordinates, where each
* coordinate is a list of two elements
* coordinate is a list of two elements
* @return JSON of list of coordinates
*
*/
* @return JSON of list of coordinates
@PostMapping
(
value
=
"/route"
,
*/
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
,
@PostMapping
(
value
=
"/route"
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ArrayNode
route
(
@RequestBody
RoutingRequest
routingRequest
)
{
public
ArrayNode
route
(
@RequestBody
RoutingRequest
routingRequest
)
{
log
(
"/route"
,
RequestMethod
.
POST
,
MediaType
.
APPLICATION_JSON
,
routingRequest
);
log
(
"/route"
,
RequestMethod
.
POST
,
MediaType
.
APPLICATION_JSON
,
routingRequest
);
// route generation
//route generation
List
<
Point
>
path
=
ApplyShortestPath
.
getShortestPath
(
routingRequest
);
List
<
Coordinates
>
path
=
ApplyShortestPath
.
getShortestPath
(
routingRequest
);
ArrayNode
arrayNode
=
mapper
.
createArrayNode
();
ArrayNode
arrayNode
=
mapper
.
createArrayNode
();
for
(
Point
coordinate
:
path
)
{
for
(
Coordinates
coordinate
:
path
)
{
arrayNode
.
add
(
arrayNode
.
add
(
mapper
.
createArrayNode
()
mapper
.
createArrayNode
()
.
add
(
coordinate
.
getLat
())
.
add
(
coordinate
.
getLat
())
.
add
(
coordinate
.
getLon
()));
.
add
(
coordinate
.
getLon
())
}
);
/*
* arrayNode.add(
* mapper.createArrayNode()
* .add(50.34565)
* .add(8.14056)
* );
* arrayNode.add(
* mapper.createArrayNode()
* .add(50.34551)
* .add(8.13901)
* );
* arrayNode.add(
* mapper.createArrayNode()
* .add(50.34551)
* .add(8.13901)
* );
*/
return
arrayNode
;
}
}
/*arrayNode.add(
mapper.createArrayNode()
.add(50.34565)
.add(8.14056)
);
arrayNode.add(
mapper.createArrayNode()
.add(50.34551)
.add(8.13901)
);
arrayNode.add(
mapper.createArrayNode()
.add(50.34551)
.add(8.13901)
);*/
return
arrayNode
;
}
/**
/**
* Method is a dummy for now. Answers with a coordinate pair
* Method is a dummy for now. Answers with a coordinate pair
* @return JSON coordinate pair
*
* @throws IOException
* @return JSON coordinate pair
*/
* @throws IOException
@PostMapping
(
value
=
"/adressmatching"
,
*/
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
,
@PostMapping
(
value
=
"/adressmatching"
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ObjectNode
adressmatching
(
@RequestBody
AdressRequest
adressRequest
)
throws
IOException
{
public
ObjectNode
adressmatching
(
@RequestBody
AdressRequest
adressRequest
)
throws
IOException
{
log
(
"/adressmatching"
,
RequestMethod
.
POST
,
MediaType
.
APPLICATION_JSON
,
adressRequest
);
log
(
"/adressmatching"
,
RequestMethod
.
POST
,
MediaType
.
APPLICATION_JSON
,
adressRequest
);
// resolve adress with map matching method
// resolve adress with map matching method
Coordinates
coordinates
=
MapMatcher
.
getCoordinates
(
adressRequest
.
getAdress
());
Coordinates
coordinates
=
MapMatcher
.
getCoordinates
(
adressRequest
.
getAdress
());
ObjectNode
objectNode
=
mapper
.
createObjectNode
();
objectNode
.
set
(
"coordinates"
,
mapper
.
createObjectNode
()
ObjectNode
objectNode
=
mapper
.
createObjectNode
();
.
put
(
"lat"
,
coordinates
.
getLat
())
objectNode
.
put
(
"coordinates"
,
.
put
(
"lon"
,
coordinates
.
getLon
()));
mapper
.
createObjectNode
()
objectNode
.
put
(
"error_code"
,
0
);
.
put
(
"lat"
,
coordinates
.
getLat
())
.
put
(
"lon"
,
coordinates
.
getLon
())
return
objectNode
;
);
}
objectNode
.
put
(
"error_code"
,
0
);
return
objectNode
;
}
private
void
log
(
String
endpoint
,
RequestMethod
method
,
MediaType
type
,
Object
requestBody
)
{
private
void
log
(
String
endpoint
,
RequestMethod
method
,
MediaType
type
,
Object
requestBody
)
{
System
.
out
.
println
(
String
.
format
(
"""
System
.
out
.
println
(
String
.
format
(
"""
Received the following request:
Received the following request:
Endpoint: %s
Endpoint: %s
Method: %s
Method: %s
Media type: %s
Media type: %s
Body: %s
Body: %s
"""
,
endpoint
,
method
,
type
,
requestBody
));
"""
,
endpoint
,
method
,
type
,
requestBody
));
}
}
}
}
Loading