fix: remove manual position coordinate adjustment

This commit is contained in:
dancingCycle 2022-10-04 08:00:56 +02:00
parent 0ef3f0caea
commit be273f5b92
3 changed files with 12 additions and 9 deletions

View File

@ -12,12 +12,12 @@ export default function Map({messages}) {
/*lat and lon of Braunschweig,DE*/
const position = [52.26594, 10.52673]
//TODO make this switch available via configuration
const hasGtfs = true;
const hasGtfs = false;
return (
<>
<MapContainer
center={position}
zoom={5}
zoom={4}
minZoom={2}
scrollWheelZoom={true}
>

View File

@ -10,7 +10,7 @@ export default function MapPage() {
//console.log('getData() start...');
try {
/*TODO handle errors: https://www.valentinog.com/blog/await-react/*/
let url = 'https://soll.vbn.de/vehicle-positions';
let url = 'https://api.entur.io/realtime/v1/gtfs-rt/vehicle-positions';
//let url = 'http://localhost:8080/vehicle-positions';
const res = await axios.get(url,
{

View File

@ -26,12 +26,15 @@ export default function parseMessages(buffer){
//remove tailing dot
//match a dot when it is followed by a whitespace or the end of the string
/*TODO Is this precaution required?*/
let latFormed = position.latitude === undefined ? -360 : position.latitude.toString().replace(/\.+$/, "");
//TODO Handle error! Placing a decimal point at a fixed place does not work in general!
//let posLat=position.latitude;
//console.log(`getVehPos() posLat:${posLat}`);
//let latFormed = position.latitude === undefined ? -360 : position.latitude.toString().replace(/\.+$/, "");
//console.log(`getVehPos() latFormed:${latFormed}`);
latFormed=charIntoString(latFormed,latFormed.length - 7,'.');
//latFormed=charIntoString(latFormed,latFormed.length - 7,'.');
//console.log(`getVehPos() latFormed:${latFormed}`);
let lonFormed = position.longitude === undefined ? -720 : position.longitude.toString().replace(/\.+$/, "");
lonFormed=charIntoString(lonFormed,lonFormed.length - 7,'.');
//let lonFormed = position.longitude === undefined ? -720 : position.longitude.toString().replace(/\.+$/, "");
//lonFormed=charIntoString(lonFormed,lonFormed.length - 7,'.');
//console.log(`getVehPos() lonFormed:${lonFormed}`);
const now= new Date();
const message={
@ -52,8 +55,8 @@ export default function parseMessages(buffer){
tripId: trip.trip_id === undefined ? -1 : parseInt(trip.trip_id,10) || -2,
/*The route_id from the GTFS that this selector refers to.*/
routeId: trip.route_id === undefined ? -1 : parseInt(trip.route_id,10) || -2,
lat: latFormed,
lon: lonFormed,
lat: position.latitude,
lon: position.longitude,
};
messages.push(message);
} else {