Commit 0e0a3bfe authored by M2947's avatar M2947 😎
Browse files

Merge branch 'Jaber_v01' into 'master'

Jaber v01

See merge request !1
parents 37328076 5127d286
Pipeline #243024 passed with stages
in 2 seconds
File added
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
#vscode
.vscode
\ No newline at end of file
# DataAnalytics
# Project Subject
8. Tavara- ja raskaan liikenteen avoimet datalähteen
* Meriliikenteen (satamiin saapuvat laivat jne.) avoimen rajapintojen selvittäminen
* Raskaanliikenteen määrien selvittäminen satamien läheisyydessä olevien LAM-pisteiden avulla (LAM-pisteistä saa ajoneuvoluokat selville)
* Raskaanliikenteen liikennemäärät Suomessa (LAM-pisteet)
* Junaliikenteen rajapintojen selvittäminen (erityisesti tavaraliikenne)
* Lentoliikenne (onko avointa rajapintaa Suomessa (finavia)? Saako https://www.flightradar24.com jotakin irti, saapuvat rahtikoneet Helsinki-Vantaa?
# Documentation
## LAM reports
LAM reports can be found from the link:
https://aineistot.vayla.fi/lam/reports/
## LAM raw data
From the LAM raw data service you can get measurement data starting from year 1995. New data comes once a day at 03:00-04:00 AM.
### Retrieving data
Getting data needs the files exact path and name in following format:
https://aineistot.vayla.fi/lam/rawdata/[year]/[ELY]/lamraw_[lam_id]_[yearshort]_[day_number].csv
where:
* year = year starting from 1995
* ELY = ELY-L area number in 2 digits.
note that Area numbers are different from the: http://www.tilastokeskus.fi/meta/luokitukset/ely/001-2019/index.html
01 Uusimaa (contains also: Häme)<br>
02 Varsinais-Suomi (contains also: Satakunta)<br>
03 Kaakkois-Suomi<br>
04 Pirkanmaa<br>
08 Pohjois-Savo (contains also: Etelä-Savo and Pohjois-Karjala)<br>
09 Keski-Suomi<br>
10 Etelä-Pohjanmaa (contains also: Pohjanmaa)<br>
12 Pohjois-Pohjanmaa (contains also: Kainuu)<br>
14 Lappi<br>
* lam_id = LAM point ID
* yearshort = 2 last digits of year
* day_number = day number from beginning of the year
for example the path for LAM point 101 in Uusimaa on 1.2.2017 will be :
https://aineistot.vayla.fi/lam/rawdata/2017/01/lamraw_101_17_32.csv
### Output file description
The output file will be in CSV format, where its headings are as follow:
* Point id
* year
* day number in year
* hour
* minute
* second
* 100th of a second
* length (m)
* lane
* direction
* vehicle class
* speed (km/h)
* faulty (0= valid, 1=incorrect)
* total time
* interval
* jonoalku
#### Vehicle classes
1 HA-PA (henkilö- tai pakettiauto)<br>
2 KAIP (kuorma-auto ilman perävaunua)<br>
3 Linja-autot<br>
4 KAPP (kuorma-auto ja puoliperävaunu)<br>
5 KATP (kuorma-auto ja täysperävaunu)<br>
6 HA + PK (henkilöauto ja peräkärry)<br>
7 HA + AV (henkilöauto ja asuntovaunu)<br>
## Digitraffic.fi API
Link to Digitraffic website:
https://www.digitraffic.fi/en/road-traffic/
## Road Traffic
Digitraffic.fi provides free information about road traffic through API.
#### Current data from LAM stations
https://tie.digitraffic.fi/api/v1/data/tms-data
https://tie.digitraffic.fi/api/v1/data/tms-data/{id}
Response message contains TMS (Traffic Measurement System)–stations measurement data.
Every TMS station provides information about traffic amounts and measured average speeds.
Data is updated almost in real time but information is cached. Actual update interval is one minute. Real time data can be read from WebSocket.
Related metadata:
https://tie.digitraffic.fi/api/v3/metadata/tms-stations
https://tie.digitraffic.fi/api/v3/metadata/tms-sensors
# TMS point(LAM points) information
TMS information can be found from the following url:
https://tie.digitraffic.fi/api/v3/metadata/tms-stations
note : The province code in TMS information API are different from the province code that is the raw data url.
please make sure to use the right province code to get right data.
Province codes in raw data url and its equivalent in TMS station API are as follow:
|Province name| Province code in raw data URL| Province code in [TMS station API](https://tie.digitraffic.fi/api/v3/metadata/tms-stations)|
| --- | --- | --- |
| Uusimaa, Häme | 01 | 01, 05, 07 |
| Varsinais-Suomi , Satakunta | 02 | 02, 04 |
| Kaakkois-Suomi| 03 | 08 , 09 |
| Pirkanmaa | 04 | 06 |
| Pohjois-Savo, Etelä-Savo, Pohjois-Karjala | 08 | 11, 10,12 |
| Keski-Suomi| 09 | 13 |
| Etelä-Pohjanmaa, Pohjanmaa, Keski-Pohjanmaa | 10 | 14, 15, 16 |
| Pohjois-Pohjanmaa, Kainuu | 12 | 17, 18 |
| Lappi| 14 | 19 |
# Report for the internship project
start date 1.6.2020
\ No newline at end of file
//Part1: Express Web Server
var express = require('express');
var cors = require('cors');
var app = express();
app.use(cors());
app.use("/",require("./routes/test.js"))
app.use("/api/vehicle/", require('./routes/api/vehicles/vehicle'));
var port = 3030;
app.listen(port, function () {
console.log(`server running on http://localhost:${port}`);
});
This diff is collapsed.
{
"name": "backend",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.19.2",
"cors": "^2.8.5",
"ejs": "^3.1.3",
"express": "^4.17.1",
"express-stream": "^0.8.0",
"nodemon": "^2.0.4",
"python-shell": "^2.0.1",
"router": "^1.3.5"
}
}
const express = require('express');
const router = express.Router();
const axios = require('axios');
//Part2: Express Get Request for Covid-19 Time Series data
router.get('/',function (req, res) {
var year = req.query.year;
var areaID = req.query.areaID;
var lamID = req.query.lamID;
var startDayNumber = req.query.startDayNumber;
var endDayNumber = req.query.endDayNumber;
//var vehicleClass =req.query.vehicleClass;
console.log(req.query);
if(endDayNumber== undefined | endDayNumber =="" | endDayNumber ==NaN)endDayNumber=NaN;
var spawn = require('child_process').spawn;
var childProcess = spawn('python', ['../python/cars/lamData.py',
year,
areaID,
lamID,
startDayNumber,
endDayNumber
//,vehicleClass,
]
,{shell: true});
// childProcess.stdout.on('data', function (data) {
//
// res.send(data.toString());
//
// });
var uint8arrayToString = function(data){
return String.fromCharCode.apply(null, data);
};
var error;
// Handle normal output
childProcess.stdout.on('data', (data) => {
console.log('ind stdout',uint8arrayToString(data));
//res.send(uint8arrayToString(data));
res.write(data,()=>{
let finish = res.writableFinished
console.log("is finished: " ,finish)
})
});
// Handle error output
childProcess.stderr.on('data', (data) => {
//As said before, convert the Uint8Array to a readable string.
console.log('In stderr',uint8arrayToString(data));
error = uint8arrayToString(data);
});
childProcess.on('exit', (code) => {
if (code===1){
res.status(404)
res.end(error);
}
else {
res.end()
}
console.log("Process quit with code : " + code);
});
});
module.exports = router
\ No newline at end of file
const express = require('express');
const router = express.Router();
const axios = require('axios');
//Part2: Express Get Request for Covid-19 Time Series data
router.get('/',function (req, res) {
var data = req.query.data;
console.log(req.query)
var spawn = require('child_process').spawn;
var childProcess = spawn('python', ['../python/test.py',
data,
]
,{shell: true});
// childProcess.stdout.on('data', function (data) {
//
// res.send(data.toString());
//
// });
var uint8arrayToString = function(data){
return String.fromCharCode.apply(null, data);
};
// Handle normal output
childProcess.stdout.on('data', (data) => {
console.log(uint8arrayToString(data));
res.send(data);
console.log(typeof data)
});
// Handle error output
childProcess.stderr.on('data', (data) => {
// As said before, convert the Uint8Array to a readable string.
console.log(uint8arrayToString(data));
});
childProcess.on('exit', (code) => {
console.log("Process quit with code : " + code);
});
});
module.exports = router
\ No newline at end of file
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts
In the project directory, you can run:
### `npm start`
Runs the app in the development mode.<br />
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will reload if you make edits.<br />
You will also see any lint errors in the console.
### `npm test`
Launches the test runner in the interactive watch mode.<br />
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `npm run build`
Builds the app for production to the `build` folder.<br />
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.<br />
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
### Code Splitting
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
### Analyzing the Bundle Size
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
### Making a Progressive Web App
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
### Advanced Configuration
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
### Deployment
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
### `npm run build` fails to minify
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
This diff is collapsed.
{
"name": "traffic",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"apexcharts": "^3.19.2",
"axios": "^0.19.2",
"bootstrap": "^4.5.0",
"chart.js": "^2.9.3",
"react": "^16.13.1",
"react-apexcharts": "^1.3.7",
"react-bootstrap": "^1.0.1",
"react-chartjs-2": "^2.9.0",
"react-dom": "^16.13.1",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<title>React App</title>
</head>
<body style="background-color: rgb(236, 236, 236);">
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>
Markdown is supported
0%