김성연

tjddus: add MapView, Marker, StartFinshLocation frontend, update backend login

Showing 36 changed files with 772 additions and 23 deletions
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<module type="WEB_MODULE" version="4">
3 + <component name="NewModuleRootManager">
4 + <content url="file://$MODULE_DIR$" />
5 + <orderEntry type="inheritedJdk" />
6 + <orderEntry type="sourceFolder" forTests="false" />
7 + </component>
8 +</module>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project version="4">
3 + <component name="JavaScriptSettings">
4 + <option name="languageLevel" value="JSX" />
5 + </component>
6 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project version="4">
3 + <component name="ProjectModuleManager">
4 + <modules>
5 + <module fileurl="file://$PROJECT_DIR$/.idea/code.iml" filepath="$PROJECT_DIR$/.idea/code.iml" />
6 + </modules>
7 + </component>
8 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project version="4">
3 + <component name="VcsDirectoryMappings">
4 + <mapping directory="$PROJECT_DIR$/locationTest/expo-location-example" vcs="Git" />
5 + <mapping directory="$PROJECT_DIR$/my-project" vcs="Git" />
6 + <mapping directory="$PROJECT_DIR$/render_server_react_native" vcs="Git" />
7 + <mapping directory="$PROJECT_DIR$/render_server_react_native/@expo/vector-icons" vcs="Git" />
8 + </component>
9 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project version="4">
3 + <component name="ChangeListManager">
4 + <list default="true" id="940f1aa2-9848-4abc-bd75-a3db12d9e8e1" name="Default Changelist" comment="">
5 + <change afterPath="$PROJECT_DIR$/render_server_react_native/AuthContext.js" afterDir="false" />
6 + <change afterPath="$PROJECT_DIR$/render_server_react_native/components/CurrentUserLocationComponent.js" afterDir="false" />
7 + <change afterPath="$PROJECT_DIR$/render_server_react_native/components/LoginComponent.js" afterDir="false" />
8 + <change afterPath="$PROJECT_DIR$/render_server_react_native/components/MyProfileComponent.js" afterDir="false" />
9 + <change afterPath="$PROJECT_DIR$/render_server_react_native/components/SignUpComponent.js" afterDir="false" />
10 + <change afterPath="$PROJECT_DIR$/render_server_react_native/constants/layout.js" afterDir="false" />
11 + <change afterPath="$PROJECT_DIR$/render_server_react_native/navigations/SelectOrTakePhotoStackNavigation.js" afterDir="false" />
12 + <change afterPath="$PROJECT_DIR$/render_server_react_native/navigations/SelectOrTakePhotoTabNavigation.js" afterDir="false" />
13 + <change afterPath="$PROJECT_DIR$/render_server_react_native/navigations/TabNavigation.js" afterDir="false" />
14 + <change afterPath="$PROJECT_DIR$/render_server_react_native/reducers/index.js" afterDir="false" />
15 + <change afterPath="$PROJECT_DIR$/render_server_react_native/reducers/location.js" afterDir="false" />
16 + <change afterPath="$PROJECT_DIR$/render_server_react_native/reducers/user.js" afterDir="false" />
17 + <change afterPath="$PROJECT_DIR$/render_server_react_native/sagas/index.js" afterDir="false" />
18 + <change afterPath="$PROJECT_DIR$/render_server_react_native/sagas/location.js" afterDir="false" />
19 + <change afterPath="$PROJECT_DIR$/render_server_react_native/sagas/user.js" afterDir="false" />
20 + <change afterPath="$PROJECT_DIR$/render_server_react_native/screens/Gallery.js" afterDir="false" />
21 + <change afterPath="$PROJECT_DIR$/render_server_react_native/screens/Login.js" afterDir="false" />
22 + <change afterPath="$PROJECT_DIR$/render_server_react_native/screens/Main.js" afterDir="false" />
23 + <change afterPath="$PROJECT_DIR$/render_server_react_native/screens/Maps.js" afterDir="false" />
24 + <change afterPath="$PROJECT_DIR$/render_server_react_native/screens/Profile.js" afterDir="false" />
25 + <change afterPath="$PROJECT_DIR$/render_server_react_native/screens/TakePhoto.js" afterDir="false" />
26 + <change afterPath="$PROJECT_DIR$/render_server_react_native/screens/UploadPhoto.js" afterDir="false" />
27 + <change afterPath="$PROJECT_DIR$/render_server_react_native/store.js" afterDir="false" />
28 + </list>
29 + <option name="SHOW_DIALOG" value="false" />
30 + <option name="HIGHLIGHT_CONFLICTS" value="true" />
31 + <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
32 + <option name="LAST_RESOLUTION" value="IGNORE" />
33 + </component>
34 + <component name="FileTemplateManagerImpl">
35 + <option name="RECENT_TEMPLATES">
36 + <list>
37 + <option value="JavaScript File" />
38 + </list>
39 + </option>
40 + </component>
41 + <component name="Git.Settings">
42 + <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/render_server_react_native" />
43 + </component>
44 + <component name="ProjectId" id="1baLVrrFUlmMeeq9EFLzndP0zML" />
45 + <component name="ProjectLevelVcsManager" settingsEditedManually="true">
46 + <ConfirmationsSetting value="2" id="Add" />
47 + </component>
48 + <component name="ProjectViewState">
49 + <option name="hideEmptyMiddlePackages" value="true" />
50 + <option name="showExcludedFiles" value="true" />
51 + <option name="showLibraryContents" value="true" />
52 + </component>
53 + <component name="PropertiesComponent">
54 + <property name="ASKED_ADD_EXTERNAL_FILES" value="true" />
55 + <property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
56 + <property name="WebServerToolWindowFactoryState" value="false" />
57 + <property name="last_opened_file_path" value="$PROJECT_DIR$" />
58 + <property name="nodejs_package_manager_path" value="npm" />
59 + </component>
60 + <component name="RecentsManager">
61 + <key name="CopyFile.RECENT_KEYS">
62 + <recent name="$PROJECT_DIR$/user_and_post_server" />
63 + <recent name="$PROJECT_DIR$" />
64 + <recent name="$PROJECT_DIR$/my-project/sagas" />
65 + <recent name="$PROJECT_DIR$/my-project/reducers" />
66 + </key>
67 + </component>
68 + <component name="SvnConfiguration">
69 + <configuration />
70 + </component>
71 + <component name="TaskManager">
72 + <task active="true" id="Default" summary="Default task">
73 + <changelist id="940f1aa2-9848-4abc-bd75-a3db12d9e8e1" name="Default Changelist" comment="" />
74 + <created>1588865284571</created>
75 + <option name="number" value="Default" />
76 + <option name="presentableId" value="Default" />
77 + <updated>1588865284571</updated>
78 + <workItem from="1588865285717" duration="748000" />
79 + <workItem from="1588875642765" duration="2528000" />
80 + <workItem from="1588878826886" duration="6053000" />
81 + <workItem from="1588919313007" duration="576000" />
82 + <workItem from="1589357475573" duration="2335000" />
83 + <workItem from="1589800232399" duration="230000" />
84 + <workItem from="1589865778893" duration="5143000" />
85 + <workItem from="1589960196464" duration="11230000" />
86 + <workItem from="1590036154083" duration="405000" />
87 + <workItem from="1590039473513" duration="2083000" />
88 + <workItem from="1590082072338" duration="1708000" />
89 + <workItem from="1590302730003" duration="745000" />
90 + <workItem from="1590304674918" duration="364000" />
91 + <workItem from="1590305558438" duration="34000" />
92 + <workItem from="1590392477108" duration="7362000" />
93 + <workItem from="1590405423629" duration="8216000" />
94 + </task>
95 + <servers />
96 + </component>
97 + <component name="TypeScriptGeneratedFilesManager">
98 + <option name="version" value="1" />
99 + </component>
100 + <component name="VcsManagerConfiguration">
101 + <option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
102 + </component>
103 + <component name="WindowStateProjectService">
104 + <state x="368" y="125" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1590082196823">
105 + <screen x="0" y="23" width="1440" height="877" />
106 + </state>
107 + <state x="368" y="125" key="#com.intellij.execution.impl.EditConfigurationsDialog/0.23.1440.877@0.23.1440.877" timestamp="1590082196823" />
108 + <state x="710" y="271" key="#com.intellij.fileTypes.FileTypeChooser" timestamp="1588881921466">
109 + <screen x="0" y="23" width="1440" height="877" />
110 + </state>
111 + <state x="710" y="271" key="#com.intellij.fileTypes.FileTypeChooser/0.23.1440.877@0.23.1440.877" timestamp="1588881921466" />
112 + <state width="784" height="229" key="GridCell.Tab.0.bottom" timestamp="1588878772214">
113 + <screen x="0" y="23" width="1440" height="877" />
114 + </state>
115 + <state width="784" height="229" key="GridCell.Tab.0.bottom/0.23.1440.877@0.23.1440.877" timestamp="1588878772214" />
116 + <state width="784" height="229" key="GridCell.Tab.0.center" timestamp="1588878772213">
117 + <screen x="0" y="23" width="1440" height="877" />
118 + </state>
119 + <state width="784" height="229" key="GridCell.Tab.0.center/0.23.1440.877@0.23.1440.877" timestamp="1588878772213" />
120 + <state width="784" height="229" key="GridCell.Tab.0.left" timestamp="1588878772212">
121 + <screen x="0" y="23" width="1440" height="877" />
122 + </state>
123 + <state width="784" height="229" key="GridCell.Tab.0.left/0.23.1440.877@0.23.1440.877" timestamp="1588878772212" />
124 + <state width="784" height="229" key="GridCell.Tab.0.right" timestamp="1588878772213">
125 + <screen x="0" y="23" width="1440" height="877" />
126 + </state>
127 + <state width="784" height="229" key="GridCell.Tab.0.right/0.23.1440.877@0.23.1440.877" timestamp="1588878772213" />
128 + <state x="702" y="213" width="670" height="676" key="search.everywhere.popup" timestamp="1588882527475">
129 + <screen x="0" y="23" width="1440" height="877" />
130 + </state>
131 + <state x="702" y="213" width="670" height="676" key="search.everywhere.popup/0.23.1440.877@0.23.1440.877" timestamp="1588882527475" />
132 + <state x="767" y="383" key="vcs.readOnlyHandler.ReadOnlyStatusDialog" timestamp="1588882053803">
133 + <screen x="0" y="23" width="1440" height="877" />
134 + </state>
135 + <state x="767" y="383" key="vcs.readOnlyHandler.ReadOnlyStatusDialog/0.23.1440.877@0.23.1440.877" timestamp="1588882053803" />
136 + </component>
137 + <component name="XDebuggerManager">
138 + <breakpoint-manager>
139 + <breakpoints>
140 + <line-breakpoint enabled="true" type="javascript">
141 + <url>file://$PROJECT_DIR$/my-project/screens/HomeScreen.js</url>
142 + <option name="timeStamp" value="1" />
143 + </line-breakpoint>
144 + </breakpoints>
145 + </breakpoint-manager>
146 + </component>
147 +</project>
...\ No newline at end of file ...\ No newline at end of file
...@@ -9,6 +9,7 @@ npm-debug.* ...@@ -9,6 +9,7 @@ npm-debug.*
9 *.orig.* 9 *.orig.*
10 web-build/ 10 web-build/
11 web-report/ 11 web-report/
12 +node_modules/
12 13
13 # macOS 14 # macOS
14 .DS_Store 15 .DS_Store
......
1 +import React, {useState, useEffect} from 'react';
2 +import MapView, {Marker} from 'react-native-maps';
3 +import {StyleSheet, Text, TextInput, View, TouchableOpacity} from 'react-native';
4 +import screen from '../constants/layout';
5 +import {useSelector, useDispatch} from "react-redux";
6 +import * as Location from 'expo-location';
7 +import {set} from "react-native-reanimated";
8 +import {MaterialCommunityIcons} from "@expo/vector-icons";
9 +import {SET_LOC_REQUEST} from "../reducers/location";
10 +
11 +
12 +const StartAndFinishLocationComponent = () => {
13 + const [hasPermission, setHasPermission] = useState(false);
14 + const [startTextLocation, setStartTextLocation] = useState('');
15 + const [finishTextLocation, setFinishTextLocation] = useState('');
16 + const [userLocation, setUserLocation] = useState(null);
17 +
18 + const onChangeStartLocation = async (startTextLocation) => {
19 + setStartTextLocation(startTextLocation);
20 + };
21 +
22 + const onChangeFinishLocation = (finishTextLocation) => {
23 + setFinishTextLocation(finishTextLocation);
24 + };
25 +
26 + const dispatch = useDispatch();
27 + const setLocation = async () => {
28 + if (!startTextLocation || !finishTextLocation) {
29 + return
30 + }
31 + console.log(startTextLocation, finishTextLocation);
32 + await dispatch({
33 + type: SET_LOC_REQUEST,
34 + data: {
35 + startTextLocation,
36 + finishTextLocation
37 + }
38 + }
39 + )
40 +
41 + };
42 +
43 + return (
44 + <View style={styles.container}>
45 + <View style={styles.input}>
46 + <Text style={styles.textStyle}>출발지</Text>
47 + <TextInput
48 + style={styles.inputText}
49 + onChangeText={onChangeStartLocation}
50 + />
51 + <TouchableOpacity>
52 + <MaterialCommunityIcons color={'grey'} name={'map-marker'} size={30}/>
53 + </TouchableOpacity>
54 +
55 + </View>
56 + <View style={styles.input}>
57 + <Text style={styles.textStyle}>도착지</Text>
58 + <TextInput
59 + style={styles.inputText}
60 + onChangeText={onChangeFinishLocation}
61 + />
62 + </View>
63 + <View style={{flexDirection: 'row'}}>
64 + <TouchableOpacity style={styles.buttonStyle} onPress={setLocation}>
65 + <Text>MAP설정</Text>
66 + </TouchableOpacity>
67 + <TouchableOpacity style={styles.buttonStyle}>
68 + <Text>사용자최적경로검색</Text>
69 + </TouchableOpacity>
70 + </View>
71 + </View>
72 + )
73 +};
74 +
75 +export default StartAndFinishLocationComponent;
76 +
77 +const styles = StyleSheet.create({
78 + container: {
79 + marginLeft: 20,
80 + marginRight: 20,
81 + },
82 + input: {
83 + borderRadius: 10,
84 + backgroundColor: 'lightgrey',
85 + paddingLeft: 10,
86 + paddingRight: 10,
87 + width: 300,
88 + height: 40,
89 + alignItems: 'center',
90 + flexDirection: 'row',
91 + justifyContent: 'space-between',
92 + borderBottomColor: '#bbb',
93 + marginBottom: 10
94 + // borderBottomWidth: StyleSheet.hairlineWidth,
95 + },
96 + inputText: {
97 + flex: 1,
98 + },
99 + textStyle: {
100 + fontWeight: 'bold',
101 + fontSize: 17,
102 + marginRight: 15,
103 + },
104 + buttonStyle: {
105 + flex: 1,
106 + backgroundColor: '#ecf0f1',
107 + alignItems: 'center',
108 + justifyContent: 'center',
109 + width: 30,
110 + height: 30,
111 + borderWidth: 1,
112 + borderColor: 'black',
113 + marginBottom: 20
114 +
115 + }
116 +});
1 -const host = '172.20.10.3';
2 -
3 -export default host;
...\ No newline at end of file ...\ No newline at end of file
1 +export const host = '172.20.10.3';
2 +export const coordAPIKEY = 'CDCF07BD-2CE4-33D9-BA13-D6CE4360A2B3';
......
This diff could not be displayed because it is too large.
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
17 "expo-asset": "^8.1.4", 17 "expo-asset": "^8.1.4",
18 "expo-camera": "~8.2.0", 18 "expo-camera": "~8.2.0",
19 "expo-font": "^8.1.1", 19 "expo-font": "^8.1.1",
20 + "expo-location": "~8.1.0",
20 "expo-media-library": "~8.1.0", 21 "expo-media-library": "~8.1.0",
21 "expo-permissions": "~8.1.0", 22 "expo-permissions": "~8.1.0",
22 "expo-web-browser": "^8.2.1", 23 "expo-web-browser": "^8.2.1",
......
1 import {combineReducers} from "redux"; 1 import {combineReducers} from "redux";
2 import user from './user'; 2 import user from './user';
3 -// import post from './post'; 3 +import location from './location';
4 4
5 const rootReducer = combineReducers({ 5 const rootReducer = combineReducers({
6 user, 6 user,
7 - // post 7 + location
8 }); 8 });
9 9
10 export default rootReducer; 10 export default rootReducer;
...\ No newline at end of file ...\ No newline at end of file
......
1 +export const initialState = {
2 + startLocation: null,
3 + finishLocation: null,
4 +
5 + settingLocation: false,
6 +
7 + info: '',
8 +};
9 +
10 +export const SET_LOC_REQUEST = 'SET_LOC_REQUEST';
11 +export const SET_LOC_SUCCESS = 'SET_LOC_SUCCESS';
12 +export const SET_LOC_FAILURE = 'SET_LOC_FAILURE';
13 +
14 +export default (state = initialState, action) => {
15 + switch (action.type) {
16 +
17 + case SET_LOC_REQUEST: {
18 + return {
19 + ...state,
20 + settingLocation: true,
21 + }
22 + }
23 +
24 + case SET_LOC_SUCCESS: {
25 + const {startLocation, finishLocation} = action.data;
26 + return {
27 + ...state,
28 + startLocation,
29 + finishLocation,
30 + isLoggingIn: false,
31 + };
32 + }
33 +
34 + case SET_LOC_FAILURE: {
35 + const {info} = action.data;
36 + return {
37 + ...state,
38 + settingLocation: false,
39 + info,
40 + }
41 + }
42 +
43 + default: {
44 + return {
45 + ...state,
46 + };
47 + }
48 + }
49 +};
...\ No newline at end of file ...\ No newline at end of file
1 import {all, fork} from 'redux-saga/effects'; 1 import {all, fork} from 'redux-saga/effects';
2 2
3 import user from './user'; 3 import user from './user';
4 -// import post from './post'; 4 +import location from './location';
5 5
6 -export default function* rootSaga(){ 6 +export default function* rootSaga() {
7 yield all([ 7 yield all([
8 fork(user), 8 fork(user),
9 - // fork(post) 9 + fork(location),
10 ]) 10 ])
11 } 11 }
...\ No newline at end of file ...\ No newline at end of file
......
1 +import {all, call, fork, delay, put, takeEvery, takeLatest} from 'redux-saga/effects';
2 +import axios from 'axios';
3 +import {coordAPIKEY} from '../env';
4 +import {
5 + SET_LOC_REQUEST,
6 + SET_LOC_SUCCESS,
7 + SET_LOC_FAILURE,
8 +} from "../reducers/location";
9 +
10 +function setLocationAPI(data) {
11 + const {startTextLocation, finishTextLocation} = data;
12 + console.log(startTextLocation, finishTextLocation);
13 + const startRes = axios.get(`http://api.vworld.kr/req/address?service=address&request=getcoord&version=2.0&crs=epsg:4326&address=${startTextLocation}&refine=true&simple=false&format=xml&type=road&key=${coordAPIKEY}`);
14 + const finishRes = axios.get(`http://api.vworld.kr/req/address?service=address&request=getcoord&version=2.0&crs=epsg:4326&address=${finishTextLocation}&refine=true&simple=false&format=xml&type=road&key=${coordAPIKEY}`);
15 +
16 + return {startRes, finishRes};
17 +}
18 +
19 +
20 +function* setLocation(action) {
21 + try {
22 + console.log('saga의 setLocation', action.data);
23 + const res = yield call(setLocationAPI, action.data);
24 + console.log(res.startRes, res.finishRes);
25 + const {result} = res.startRes;
26 + console.log(result);
27 + } catch (e) {
28 + console.error(e);
29 + }
30 +};
31 +
32 +function* watchSetLocation() {
33 + console.log('watchSetLocation');
34 + yield takeLatest(SET_LOC_REQUEST, setLocation);
35 +}
36 +
37 +export default function* locationSaga() {
38 + yield all([
39 + fork(watchSetLocation),
40 + ]);
41 +};
...\ No newline at end of file ...\ No newline at end of file
...@@ -37,6 +37,9 @@ function loginAPI(data) { ...@@ -37,6 +37,9 @@ function loginAPI(data) {
37 const {email, password} = data; 37 const {email, password} = data;
38 console.log(email, password); 38 console.log(email, password);
39 console.log(`http://${host}:4001/user/login`); 39 console.log(`http://${host}:4001/user/login`);
40 + // const res1 = axios.get(`http://${host}:4001/user/test`, {
41 + // withCredentials: true
42 + // });
40 return axios.post(`http://${host}:4001/user/login`, { 43 return axios.post(`http://${host}:4001/user/login`, {
41 email, password 44 email, password
42 }, { 45 }, {
......
1 -import React from 'react'; 1 +import React, {useState, useEffect} from 'react';
2 -import MapView from 'react-native-maps'; 2 +import MapView, {Marker} from 'react-native-maps';
3 import {StyleSheet, Text, View, Dimensions} from 'react-native'; 3 import {StyleSheet, Text, View, Dimensions} from 'react-native';
4 import screen from '../constants/layout'; 4 import screen from '../constants/layout';
5 +import StartAndFinishLocationComponent from "../components/CurrentUserLocationComponent";
5 6
6 7
7 const Maps = () => { 8 const Maps = () => {
9 + const [initialRegion, setInitialRegion] = useState(
10 + {
11 + latitude: 37.56647,
12 + longitude: 126.977963,
13 + latitudeDelta: 0.3922,
14 + longitudeDelta: 0.3421
15 + });
16 +
8 return ( 17 return (
9 <View style={styles.container}> 18 <View style={styles.container}>
19 + <Text style={styles.textStyle}>Current User Location</Text>
20 + <StartAndFinishLocationComponent/>
10 <MapView 21 <MapView
11 style={styles.mapStyle} 22 style={styles.mapStyle}
12 - initialRegion={{ 23 + initialRegion={initialRegion}
13 - latitude: 37.78825, 24 + >
14 - longitude: -122.4324, 25 + <Marker
15 - latitudeDelta: 0.0922, 26 + coordinate={initialRegion}
16 - longitudeDelta: 0.0421 27 + title="this is a marker"
17 - }} 28 + description="this is a marker example">
18 - /> 29 + </Marker>
30 +
31 + </MapView>
19 </View> 32 </View>
20 ) 33 )
21 }; 34 };
...@@ -32,4 +45,10 @@ const styles = StyleSheet.create({ ...@@ -32,4 +45,10 @@ const styles = StyleSheet.create({
32 width: screen.width, 45 width: screen.width,
33 height: screen.height / 2, 46 height: screen.height / 2,
34 }, 47 },
48 + textStyle: {
49 + fontWeight: 'bold',
50 + fontSize: 20,
51 + color: 'grey',
52 + marginBottom: 20,
53 + }
35 }); 54 });
......
1 { 1 {
2 "development": { 2 "development": {
3 "username": "root", 3 "username": "root",
4 - "password": "test", 4 + "password": "ksy98042!",
5 "database": "capstone_design_prj1", 5 "database": "capstone_design_prj1",
6 "host": "127.0.0.1", 6 "host": "127.0.0.1",
7 "dialect": "mysql", 7 "dialect": "mysql",
......
1 +function printSearchType(result) {
2 + if (result.result.searchType == 0) {
3 + console.log("도시내 이동");
4 + } else if (result.result.searchType == 1) {
5 + console.log("도시간 직통");
6 + } else {
7 + console.log("도시간 환승");
8 + }
9 +}
10 +
11 +function printBusCount(result) {
12 + console.log("버스 결과 개수:", result.result.busCount);
13 +}
14 +
15 +function printSubwayCount(result) {
16 + console.log("지하철 결과 개수 :", result.result.subwayCount);
17 +}
18 +
19 +function printSubwayBusCount(result) {
20 + console.log("버스 + 지하철 결과 개수 : ", result.result.subwayBusCount);
21 +}
22 +
23 +function printPointDistance(result) {
24 + console.log("출발점-도착점 직선 거리 :", result.pointDistance);
25 +}
26 +
27 +function printPathType(info) {
28 + if (info.pathType == 1) {
29 + console.log("지하철");
30 + } else if (info.pathType == 2) {
31 + console.log("버스");
32 + } else if (info.pathType == 3) {
33 + console.log("지하철 + 버스");
34 + }
35 +}
36 +
37 +function printTrafficDistance(info) {
38 + console.log("대중교통 이동거리: ", info.trafficDistance);
39 +}
40 +
41 +function printTotalWalk(info) {
42 + console.log("도보 이동거리 : ", info.totalWalk);
43 +}
44 +
45 +function printTotalTime(info) {
46 + console.log("총 소요시간 : ", info.totalTime);
47 +}
48 +
49 +function printBusTransitCount(info) {
50 + console.log("버스 환승 :", info.busTransitCount, "회");
51 +}
52 +
53 +function printSubwayTransitCount(info) {
54 + console.log("지하철 환승 :", info.subwayTransit, "회");
55 +}
56 +
57 +function printFirstStartStation(info) {
58 + console.log("최초 출발 역(정류소) : ", info.firstStartStation);
59 +}
60 +
61 +function printLastEndStation(info) {
62 + console.log("최종 도착 역(정류소) : ", info.lastEndStation);
63 +}
64 +
65 +function printBusStationCount(info) {
66 + console.log(info.busStationCount, "개 정류소 이동");
67 +}
68 +
69 +function printSubwayStationCount(info) {
70 + console.log(info.subwayStationCount, "개 역 이동");
71 +}
72 +
73 +function printPath(path) {
74 + printPathType(path);
75 + printTrafficDistance(path);
76 + printTotalWalk(path);
77 + printTotalTime(path);
78 + printBusTransitCount(path);
79 + printSubwayTransitCount(path);
80 + printFirstStartStation(path);
81 + printLastEndStation(path);
82 + if (path.pathType == 1) {
83 + printSubwayStationCount(path);
84 + } else if (path.pathType == 2) {
85 + printBusStationCount(path);
86 + } else {
87 + printBusStationCount(path);
88 + printSubwayStationCount(path);
89 +
90 + }
91 +}
92 +
93 +function printSubPath(subPath) {
94 + if (subPath.trafficType == 1) {
95 + console.log("지하철이용");
96 + console.log("이동거리 : ", subPath.distance);
97 + console.log("이동 소요시간 : ", subPath.sectionTime);
98 + console.log(subPath.stationCount, "개의 역 이동");
99 + console.log(subPath.startName, "에서 승차");
100 + //startX
101 + //startY
102 + console.log("승차역 id : ", subPath.startID);
103 + console.log(subPath.endName, "에서 하차");
104 + //endX
105 + //endY
106 + console.log("하차역 id : ", subPath.endID);
107 + printSubwayLane(subPath);
108 + printPassStopList(subPath);
109 + } else if (subPath.trafficType == 2) {
110 + console.log("버스 이용");
111 + console.log("이동거리 : ", subPath.distance);
112 + console.log("이동 소요시간 : ", subPath.sectionTime);
113 + console.log("이동 정거장수 :", subPath.stationCount);
114 + console.log(subPath.startName, "에서 승차");
115 + console.log("승차 정류쟝 id : ", subPath.startID);
116 + console.log(subPath.endName, "에서 하차");
117 + console.log("하차 정류장 id : ", subPath.endID);
118 + printBusLane(subPath);
119 + printPassStopList(subPath);
120 +
121 + } else {
122 + console.log("도보 이용");
123 + console.log("이동 거리 : ", subPath.distance);
124 + console.log("이동 소요시간 : ", subPath.sectionTime);
125 + }
126 +}
127 +
128 +function printBusNumber(lane) {
129 + console.log("버스 번호 : ", lane.busNo);
130 +
131 +}
132 +
133 +function printBusID(lane) {
134 + console.log("버스 id : ", lane.busID);
135 +}
136 +
137 +function printBusLane(subPath) {
138 + console.log("===========Bus=lane============");
139 + console.log(subPath.lane.length, "개의 버스 이용가능");
140 + for (var i = 0; i < subPath.lane.length; i++) {
141 + console.log(i + 1, "번째 버스")
142 + printBusNumber(subPath.lane[i]);
143 + printBusID(subPath.lane[i]);
144 + console.log("-------------------------");
145 + }
146 +}
147 +
148 +function printSubwayLane(subPath) {
149 + console.log("===========Subway=lane============");
150 + console.log(subPath.lane.length, "개의 지하철 이용가능");
151 + for (var i = 0; i < subPath.lane.length; i++) {
152 + console.log(i + 1, "번째 지하철")
153 + console.log(subPath.lane[i]);
154 + console.log("-------------------------");
155 + }
156 +}
157 +
158 +function printStations(station) {
159 + console.log(" || ");
160 + console.log(station.index, "번째 정류쟝");
161 + console.log("정류쟝 id:", station.stationID);//=======>>>>>>실시간 API가져오기!!!
162 + console.log(station.stationName);
163 + console.log(" || ");
164 +}
165 +
166 +function printPassStopList(subPath) {
167 + console.log("=====경로 확인=======");
168 + for (var i = 0; i < subPath.passStopList.stations.length; i++) {
169 + printStations(subPath.passStopList.stations[i]);
170 + }
171 +
172 +}
173 +
174 +function printTotalCount(result) {
175 + console.log(result.totalCount, "개의 경로 존재");
176 +}
177 +
178 +function printTrainCount(result) {
179 + console.log("============기 차 이 용=================")
180 + console.log("기차 탐색 결과 개수 : ", result.trainRequest.count);
181 +}
182 +
183 +function printOBJ(obj) {
184 + console.log("출발역 :", obj.startSTN, ",id :", obj.startID);
185 + //obj.SX
186 + //obj.SY
187 + console.log("도착역 :", obj.endSTN, ", id :", obj.endID);
188 + //obj.EX
189 + //obj.EY
190 + console.log(obj.trainType);
191 + //obj.trainCode
192 + //obj.mapOBJ
193 + console.log("소요 시간 :", obj.time);
194 + console.log("요금 :", obj.payment);
195 +}
196 +
197 +function printExBusCount(result) {
198 + console.log("==========고 속 버 스 이 용===========")
199 + console.log("고속 버스 탐색 결과 개수 : ", result.exBusRequest.count);
200 +}
201 +
202 +function printOutBusCount(result) {
203 + console.log("==========시 외 버 스 이 용===========")
204 + console.log("시외 버스 탐색 결과 개수 : ", result.outBusRequest.count);
205 +}
206 +
207 +function searchPubTransPathAJAX() {
208 + console.log('hihihihih');
209 + var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
210 +
211 + var xhr = new XMLHttpRequest();
212 + //var url = "https://api.odsay.com/v1/api/searchPubTransPath?SX=126.9027279&SY=37.5349277&EX=126.9145430&EY=37.5499421&apiKey=xGDjn0UBwQ%2FazbcOasoxEs4gIcLqCBEgCFMT%2BJeVKcI";
213 + var SX = 127.077001; //경희대학교 우정원 x좌표
214 + var SY = 37.246214;//경희대학교 우정원 y좌표
215 + var EX = 126.999472;//영통역 x좌표
216 + var EY = 37.266670;//영통역 y좌표
217 + var apiKey = "%2B6RMVoSKSHcru1NjEu194wRELD7wnalJG7JDY0mc2AE";
218 + var url = "https://api.odsay.com/v1/api/searchPubTransPath?SX=" + SX + "&SY=" + SY + "&EX=" + EX + "&EY=" + EY + "&apiKey=" + apiKey;
219 + xhr.open("GET", url, true);
220 + xhr.send();
221 + xhr.onreadystatechange = function () {
222 +
223 + if (xhr.readyState == 4 && xhr.status == 200) {
224 + var result = JSON.parse(xhr.responseText);
225 + //console.log(xhr.responseText);
226 +
227 + if (result.result.searchType == 0) { //한 도시내에서 이동
228 +
229 + var totalPathSummary = new Object();//json 객체로 저장
230 + totalPathSummary.searchType = result.result.searchType;
231 + totalPathSummary.busCount = result.result.busCount;
232 + totalPathSummary.subwayCount = result.result.subwayCount;
233 + totalPathSummary.pointDistance = result.result.pointDistance;
234 +
235 + totalPathSummary = JSON.stringify(totalPathSummary);
236 + //console.log(totalPathSummary);
237 +
238 + console.log("도시내 이동");
239 + printBusCount(result);
240 + printSubwayCount(result);
241 + printSubwayBusCount(result);
242 + printPointDistance(result);
243 +
244 +
245 + var pathList = new Array();
246 +
247 + for (var i = 0; i < result.result.path.length; i++) {
248 + console.log("-----------------new 경로------------------------------");
249 + console.log(i + 1, "번째 경로");
250 +
251 + var path = new Object();
252 + path.pathType = result.result.path[i].pathType;
253 + path.info = result.result.path[i].info;
254 + path.subPathList = new Array();
255 + printPath(result.result.path[i].info);
256 +
257 +
258 + for (var j = 0; j < result.result.path[i].subPath.length; j++) {
259 + console.log("---------------");
260 + var subPath = new Object();
261 + subPath = result.result.path[i].subPath;
262 + path.subPathList.push(subPath);
263 + printSubPath(result.result.path[i].subPath[j]);
264 + }
265 + pathList.push(path);
266 + console.log("--------------------경로 끝---------------------------");
267 +
268 +
269 + }
270 + pathList = JSON.stringify(pathList);
271 + //console.log(pathList);
272 +
273 + } else if (result.result.searchType == 1) {//도시간 이동
274 + //console.log(result.result);
275 + console.log("도시 간 이동");
276 + var totalPathSummary = new Object();
277 + totalPathSummary.startCityName = result.result.startCityName;
278 + totalPathSummary.startCID = result.result.startCID;
279 + totalPathSummary.endCityName = result.result.endCityName;
280 + totalPathSummary.endCID = result.result.endCID;
281 + totalPathSummary.pointDistance = result.result.pointDistance;
282 + totalPathSummary.totalCount = result.result.totalCount;
283 +
284 + totalPathSummary = JSON.stringify(totalPathSummary);
285 + //console.log(totalPathSummary);
286 + m
287 + console.log("출발 도시:", result.result.startCityName);
288 + console.log("도착 도시:", result.result.endCityName);
289 + printPointDistance(result.result);
290 + printTotalCount(result.result);
291 + printTrainCount(result.result);//기차 이용
292 +
293 + var trainList = new Array();//기차이용
294 +
295 + for (var i = 0; i < result.result.trainRequest.count; i++) {
296 + var OBJ = new Object();
297 + OBJ = result.result.trainRequest.OBJ[i];
298 + OBJList.push(OBJ);
299 + console.log("============", i + 1, "============");
300 + printOBJ(result.result.trainRequest.OBJ[i]);
301 + }
302 + trainList = JSON.stringify(trainList);
303 +
304 + var exBusList = new Array();
305 + printExBusCount(result.result); //고속버스 이용
306 + for (var i = 0; i < result.result.exBusRequest.count; i++) {
307 + var OBJ = new Object();
308 + OBJ = result.result.exBusRequest.OBJ[i];
309 + OBJList.push(OBJ);
310 + console.log("============", i + 1, "============");
311 + printOBJ(result.result.exBusRequest.OBJ[i]);
312 + }
313 + exBusList = JSON.stringify(exBusList);
314 +
315 + var outBusList = new Array();
316 + printOutBusCount(result.result);//시외 버스 이용
317 + for (var i = 0; i < result.result.outBusRequest.count; i++) {
318 + var OBJ = new Object();
319 + OBJ = result.result.outBusRequest.OBJ[i];
320 + outBusList.push(OBJ);
321 + console.log("============", i + 1, "============");
322 + printOBJ(result.result.outBusRequest.OBJ[i]);
323 + }
324 + outBusList = JSON.stringify(outBusList);
325 + }
326 + }
327 + };
328 +}
329 +
330 +module.exports = {searchPubTransPathAJAX};
...@@ -2587,9 +2587,9 @@ ...@@ -2587,9 +2587,9 @@
2587 } 2587 }
2588 }, 2588 },
2589 "needle": { 2589 "needle": {
2590 - "version": "2.4.1", 2590 + "version": "2.5.0",
2591 - "resolved": "https://registry.npmjs.org/needle/-/needle-2.4.1.tgz", 2591 + "resolved": "https://registry.npmjs.org/needle/-/needle-2.5.0.tgz",
2592 - "integrity": "sha512-x/gi6ijr4B7fwl6WYL9FwlCvRQKGlUNvnceho8wxkwXqN8jvVmmmATTmZPRRG7b/yC1eode26C2HO9jl78Du9g==", 2592 + "integrity": "sha512-o/qITSDR0JCyCKEQ1/1bnUXMmznxabbwi/Y4WwJElf+evwJNFNwIDMCCt5IigFVxgeGBJESLohGtIS9gEzo1fA==",
2593 "requires": { 2593 "requires": {
2594 "debug": "^3.2.6", 2594 "debug": "^3.2.6",
2595 "iconv-lite": "^0.4.4", 2595 "iconv-lite": "^0.4.4",
...@@ -4428,6 +4428,11 @@ ...@@ -4428,6 +4428,11 @@
4428 "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-3.0.0.tgz", 4428 "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-3.0.0.tgz",
4429 "integrity": "sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ=" 4429 "integrity": "sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ="
4430 }, 4430 },
4431 + "xmlhttprequest": {
4432 + "version": "1.8.0",
4433 + "resolved": "https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz",
4434 + "integrity": "sha1-Z/4HXFwk/vOfnWX197f+dRcZaPw="
4435 + },
4431 "xmlhttprequest-ssl": { 4436 "xmlhttprequest-ssl": {
4432 "version": "1.5.5", 4437 "version": "1.5.5",
4433 "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz", 4438 "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz",
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
30 "pug": "2.0.0-beta11", 30 "pug": "2.0.0-beta11",
31 "sequelize": "^5.21.5", 31 "sequelize": "^5.21.5",
32 "sequelize-cli": "^5.5.1", 32 "sequelize-cli": "^5.5.1",
33 - "socket.io": "^2.3.0" 33 + "socket.io": "^2.3.0",
34 + "xmlhttprequest": "^1.8.0"
34 } 35 }
35 } 36 }
......
...@@ -4,9 +4,10 @@ const bcrypt = require('bcrypt'); ...@@ -4,9 +4,10 @@ const bcrypt = require('bcrypt');
4 const passport = require('passport'); 4 const passport = require('passport');
5 const {isLoggedIn, isNotLoggedIn} = require("./middleware"); 5 const {isLoggedIn, isNotLoggedIn} = require("./middleware");
6 const models = require('../models/index'); 6 const models = require('../models/index');
7 +const {searchPubTransPathAJAX} = require('../crawling');
7 8
8 router.get('/loadMe', isLoggedIn, (req, res, next) => { 9 router.get('/loadMe', isLoggedIn, (req, res, next) => {
9 - console.log('loadMe요청옴', req.user); 10 + // console.log('loadMe요청옴', req.user);
10 return res.json({user: req.user}); 11 return res.json({user: req.user});
11 }); 12 });
12 13
...@@ -113,4 +114,8 @@ router.get('/logout', (req, res, next) => { ...@@ -113,4 +114,8 @@ router.get('/logout', (req, res, next) => {
113 return res.send(); 114 return res.send();
114 }); 115 });
115 116
117 +router.get('/test', (req, res, next) => {
118 + searchPubTransPathAJAX();
119 +});
120 +
116 module.exports = router; 121 module.exports = router;
...\ No newline at end of file ...\ No newline at end of file
......