김성연

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

Showing 36 changed files with 772 additions and 23 deletions
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="JSX" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/code.iml" filepath="$PROJECT_DIR$/.idea/code.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/locationTest/expo-location-example" vcs="Git" />
<mapping directory="$PROJECT_DIR$/my-project" vcs="Git" />
<mapping directory="$PROJECT_DIR$/render_server_react_native" vcs="Git" />
<mapping directory="$PROJECT_DIR$/render_server_react_native/@expo/vector-icons" vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="940f1aa2-9848-4abc-bd75-a3db12d9e8e1" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/render_server_react_native/AuthContext.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/render_server_react_native/components/CurrentUserLocationComponent.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/render_server_react_native/components/LoginComponent.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/render_server_react_native/components/MyProfileComponent.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/render_server_react_native/components/SignUpComponent.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/render_server_react_native/constants/layout.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/render_server_react_native/navigations/SelectOrTakePhotoStackNavigation.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/render_server_react_native/navigations/SelectOrTakePhotoTabNavigation.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/render_server_react_native/navigations/TabNavigation.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/render_server_react_native/reducers/index.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/render_server_react_native/reducers/location.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/render_server_react_native/reducers/user.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/render_server_react_native/sagas/index.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/render_server_react_native/sagas/location.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/render_server_react_native/sagas/user.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/render_server_react_native/screens/Gallery.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/render_server_react_native/screens/Login.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/render_server_react_native/screens/Main.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/render_server_react_native/screens/Maps.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/render_server_react_native/screens/Profile.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/render_server_react_native/screens/TakePhoto.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/render_server_react_native/screens/UploadPhoto.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/render_server_react_native/store.js" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="JavaScript File" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/render_server_react_native" />
</component>
<component name="ProjectId" id="1baLVrrFUlmMeeq9EFLzndP0zML" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
<ConfirmationsSetting value="2" id="Add" />
</component>
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showExcludedFiles" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="ASKED_ADD_EXTERNAL_FILES" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="nodejs_package_manager_path" value="npm" />
</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/user_and_post_server" />
<recent name="$PROJECT_DIR$" />
<recent name="$PROJECT_DIR$/my-project/sagas" />
<recent name="$PROJECT_DIR$/my-project/reducers" />
</key>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="940f1aa2-9848-4abc-bd75-a3db12d9e8e1" name="Default Changelist" comment="" />
<created>1588865284571</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1588865284571</updated>
<workItem from="1588865285717" duration="748000" />
<workItem from="1588875642765" duration="2528000" />
<workItem from="1588878826886" duration="6053000" />
<workItem from="1588919313007" duration="576000" />
<workItem from="1589357475573" duration="2335000" />
<workItem from="1589800232399" duration="230000" />
<workItem from="1589865778893" duration="5143000" />
<workItem from="1589960196464" duration="11230000" />
<workItem from="1590036154083" duration="405000" />
<workItem from="1590039473513" duration="2083000" />
<workItem from="1590082072338" duration="1708000" />
<workItem from="1590302730003" duration="745000" />
<workItem from="1590304674918" duration="364000" />
<workItem from="1590305558438" duration="34000" />
<workItem from="1590392477108" duration="7362000" />
<workItem from="1590405423629" duration="8216000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="VcsManagerConfiguration">
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
</component>
<component name="WindowStateProjectService">
<state x="368" y="125" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1590082196823">
<screen x="0" y="23" width="1440" height="877" />
</state>
<state x="368" y="125" key="#com.intellij.execution.impl.EditConfigurationsDialog/0.23.1440.877@0.23.1440.877" timestamp="1590082196823" />
<state x="710" y="271" key="#com.intellij.fileTypes.FileTypeChooser" timestamp="1588881921466">
<screen x="0" y="23" width="1440" height="877" />
</state>
<state x="710" y="271" key="#com.intellij.fileTypes.FileTypeChooser/0.23.1440.877@0.23.1440.877" timestamp="1588881921466" />
<state width="784" height="229" key="GridCell.Tab.0.bottom" timestamp="1588878772214">
<screen x="0" y="23" width="1440" height="877" />
</state>
<state width="784" height="229" key="GridCell.Tab.0.bottom/0.23.1440.877@0.23.1440.877" timestamp="1588878772214" />
<state width="784" height="229" key="GridCell.Tab.0.center" timestamp="1588878772213">
<screen x="0" y="23" width="1440" height="877" />
</state>
<state width="784" height="229" key="GridCell.Tab.0.center/0.23.1440.877@0.23.1440.877" timestamp="1588878772213" />
<state width="784" height="229" key="GridCell.Tab.0.left" timestamp="1588878772212">
<screen x="0" y="23" width="1440" height="877" />
</state>
<state width="784" height="229" key="GridCell.Tab.0.left/0.23.1440.877@0.23.1440.877" timestamp="1588878772212" />
<state width="784" height="229" key="GridCell.Tab.0.right" timestamp="1588878772213">
<screen x="0" y="23" width="1440" height="877" />
</state>
<state width="784" height="229" key="GridCell.Tab.0.right/0.23.1440.877@0.23.1440.877" timestamp="1588878772213" />
<state x="702" y="213" width="670" height="676" key="search.everywhere.popup" timestamp="1588882527475">
<screen x="0" y="23" width="1440" height="877" />
</state>
<state x="702" y="213" width="670" height="676" key="search.everywhere.popup/0.23.1440.877@0.23.1440.877" timestamp="1588882527475" />
<state x="767" y="383" key="vcs.readOnlyHandler.ReadOnlyStatusDialog" timestamp="1588882053803">
<screen x="0" y="23" width="1440" height="877" />
</state>
<state x="767" y="383" key="vcs.readOnlyHandler.ReadOnlyStatusDialog/0.23.1440.877@0.23.1440.877" timestamp="1588882053803" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="javascript">
<url>file://$PROJECT_DIR$/my-project/screens/HomeScreen.js</url>
<option name="timeStamp" value="1" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
</project>
\ No newline at end of file
......@@ -9,6 +9,7 @@ npm-debug.*
*.orig.*
web-build/
web-report/
node_modules/
# macOS
.DS_Store
......
import React, {useState, useEffect} from 'react';
import MapView, {Marker} from 'react-native-maps';
import {StyleSheet, Text, TextInput, View, TouchableOpacity} from 'react-native';
import screen from '../constants/layout';
import {useSelector, useDispatch} from "react-redux";
import * as Location from 'expo-location';
import {set} from "react-native-reanimated";
import {MaterialCommunityIcons} from "@expo/vector-icons";
import {SET_LOC_REQUEST} from "../reducers/location";
const StartAndFinishLocationComponent = () => {
const [hasPermission, setHasPermission] = useState(false);
const [startTextLocation, setStartTextLocation] = useState('');
const [finishTextLocation, setFinishTextLocation] = useState('');
const [userLocation, setUserLocation] = useState(null);
const onChangeStartLocation = async (startTextLocation) => {
setStartTextLocation(startTextLocation);
};
const onChangeFinishLocation = (finishTextLocation) => {
setFinishTextLocation(finishTextLocation);
};
const dispatch = useDispatch();
const setLocation = async () => {
if (!startTextLocation || !finishTextLocation) {
return
}
console.log(startTextLocation, finishTextLocation);
await dispatch({
type: SET_LOC_REQUEST,
data: {
startTextLocation,
finishTextLocation
}
}
)
};
return (
<View style={styles.container}>
<View style={styles.input}>
<Text style={styles.textStyle}>출발지</Text>
<TextInput
style={styles.inputText}
onChangeText={onChangeStartLocation}
/>
<TouchableOpacity>
<MaterialCommunityIcons color={'grey'} name={'map-marker'} size={30}/>
</TouchableOpacity>
</View>
<View style={styles.input}>
<Text style={styles.textStyle}>도착지</Text>
<TextInput
style={styles.inputText}
onChangeText={onChangeFinishLocation}
/>
</View>
<View style={{flexDirection: 'row'}}>
<TouchableOpacity style={styles.buttonStyle} onPress={setLocation}>
<Text>MAP설정</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.buttonStyle}>
<Text>사용자최적경로검색</Text>
</TouchableOpacity>
</View>
</View>
)
};
export default StartAndFinishLocationComponent;
const styles = StyleSheet.create({
container: {
marginLeft: 20,
marginRight: 20,
},
input: {
borderRadius: 10,
backgroundColor: 'lightgrey',
paddingLeft: 10,
paddingRight: 10,
width: 300,
height: 40,
alignItems: 'center',
flexDirection: 'row',
justifyContent: 'space-between',
borderBottomColor: '#bbb',
marginBottom: 10
// borderBottomWidth: StyleSheet.hairlineWidth,
},
inputText: {
flex: 1,
},
textStyle: {
fontWeight: 'bold',
fontSize: 17,
marginRight: 15,
},
buttonStyle: {
flex: 1,
backgroundColor: '#ecf0f1',
alignItems: 'center',
justifyContent: 'center',
width: 30,
height: 30,
borderWidth: 1,
borderColor: 'black',
marginBottom: 20
}
});
const host = '172.20.10.3';
export default host;
\ No newline at end of file
export const host = '172.20.10.3';
export const coordAPIKEY = 'CDCF07BD-2CE4-33D9-BA13-D6CE4360A2B3';
......
This diff could not be displayed because it is too large.
......@@ -17,6 +17,7 @@
"expo-asset": "^8.1.4",
"expo-camera": "~8.2.0",
"expo-font": "^8.1.1",
"expo-location": "~8.1.0",
"expo-media-library": "~8.1.0",
"expo-permissions": "~8.1.0",
"expo-web-browser": "^8.2.1",
......
import {combineReducers} from "redux";
import user from './user';
// import post from './post';
import location from './location';
const rootReducer = combineReducers({
user,
// post
location
});
export default rootReducer;
\ No newline at end of file
......
export const initialState = {
startLocation: null,
finishLocation: null,
settingLocation: false,
info: '',
};
export const SET_LOC_REQUEST = 'SET_LOC_REQUEST';
export const SET_LOC_SUCCESS = 'SET_LOC_SUCCESS';
export const SET_LOC_FAILURE = 'SET_LOC_FAILURE';
export default (state = initialState, action) => {
switch (action.type) {
case SET_LOC_REQUEST: {
return {
...state,
settingLocation: true,
}
}
case SET_LOC_SUCCESS: {
const {startLocation, finishLocation} = action.data;
return {
...state,
startLocation,
finishLocation,
isLoggingIn: false,
};
}
case SET_LOC_FAILURE: {
const {info} = action.data;
return {
...state,
settingLocation: false,
info,
}
}
default: {
return {
...state,
};
}
}
};
\ No newline at end of file
import {all, fork} from 'redux-saga/effects';
import user from './user';
// import post from './post';
import location from './location';
export default function* rootSaga(){
export default function* rootSaga() {
yield all([
fork(user),
// fork(post)
fork(location),
])
}
\ No newline at end of file
......
import {all, call, fork, delay, put, takeEvery, takeLatest} from 'redux-saga/effects';
import axios from 'axios';
import {coordAPIKEY} from '../env';
import {
SET_LOC_REQUEST,
SET_LOC_SUCCESS,
SET_LOC_FAILURE,
} from "../reducers/location";
function setLocationAPI(data) {
const {startTextLocation, finishTextLocation} = data;
console.log(startTextLocation, finishTextLocation);
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}`);
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}`);
return {startRes, finishRes};
}
function* setLocation(action) {
try {
console.log('saga의 setLocation', action.data);
const res = yield call(setLocationAPI, action.data);
console.log(res.startRes, res.finishRes);
const {result} = res.startRes;
console.log(result);
} catch (e) {
console.error(e);
}
};
function* watchSetLocation() {
console.log('watchSetLocation');
yield takeLatest(SET_LOC_REQUEST, setLocation);
}
export default function* locationSaga() {
yield all([
fork(watchSetLocation),
]);
};
\ No newline at end of file
......@@ -37,6 +37,9 @@ function loginAPI(data) {
const {email, password} = data;
console.log(email, password);
console.log(`http://${host}:4001/user/login`);
// const res1 = axios.get(`http://${host}:4001/user/test`, {
// withCredentials: true
// });
return axios.post(`http://${host}:4001/user/login`, {
email, password
}, {
......
import React from 'react';
import MapView from 'react-native-maps';
import React, {useState, useEffect} from 'react';
import MapView, {Marker} from 'react-native-maps';
import {StyleSheet, Text, View, Dimensions} from 'react-native';
import screen from '../constants/layout';
import StartAndFinishLocationComponent from "../components/CurrentUserLocationComponent";
const Maps = () => {
const [initialRegion, setInitialRegion] = useState(
{
latitude: 37.56647,
longitude: 126.977963,
latitudeDelta: 0.3922,
longitudeDelta: 0.3421
});
return (
<View style={styles.container}>
<Text style={styles.textStyle}>Current User Location</Text>
<StartAndFinishLocationComponent/>
<MapView
style={styles.mapStyle}
initialRegion={{
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421
}}
/>
initialRegion={initialRegion}
>
<Marker
coordinate={initialRegion}
title="this is a marker"
description="this is a marker example">
</Marker>
</MapView>
</View>
)
};
......@@ -32,4 +45,10 @@ const styles = StyleSheet.create({
width: screen.width,
height: screen.height / 2,
},
textStyle: {
fontWeight: 'bold',
fontSize: 20,
color: 'grey',
marginBottom: 20,
}
});
......
{
"development": {
"username": "root",
"password": "test",
"password": "ksy98042!",
"database": "capstone_design_prj1",
"host": "127.0.0.1",
"dialect": "mysql",
......
function printSearchType(result) {
if (result.result.searchType == 0) {
console.log("도시내 이동");
} else if (result.result.searchType == 1) {
console.log("도시간 직통");
} else {
console.log("도시간 환승");
}
}
function printBusCount(result) {
console.log("버스 결과 개수:", result.result.busCount);
}
function printSubwayCount(result) {
console.log("지하철 결과 개수 :", result.result.subwayCount);
}
function printSubwayBusCount(result) {
console.log("버스 + 지하철 결과 개수 : ", result.result.subwayBusCount);
}
function printPointDistance(result) {
console.log("출발점-도착점 직선 거리 :", result.pointDistance);
}
function printPathType(info) {
if (info.pathType == 1) {
console.log("지하철");
} else if (info.pathType == 2) {
console.log("버스");
} else if (info.pathType == 3) {
console.log("지하철 + 버스");
}
}
function printTrafficDistance(info) {
console.log("대중교통 이동거리: ", info.trafficDistance);
}
function printTotalWalk(info) {
console.log("도보 이동거리 : ", info.totalWalk);
}
function printTotalTime(info) {
console.log("총 소요시간 : ", info.totalTime);
}
function printBusTransitCount(info) {
console.log("버스 환승 :", info.busTransitCount, "회");
}
function printSubwayTransitCount(info) {
console.log("지하철 환승 :", info.subwayTransit, "회");
}
function printFirstStartStation(info) {
console.log("최초 출발 역(정류소) : ", info.firstStartStation);
}
function printLastEndStation(info) {
console.log("최종 도착 역(정류소) : ", info.lastEndStation);
}
function printBusStationCount(info) {
console.log(info.busStationCount, "개 정류소 이동");
}
function printSubwayStationCount(info) {
console.log(info.subwayStationCount, "개 역 이동");
}
function printPath(path) {
printPathType(path);
printTrafficDistance(path);
printTotalWalk(path);
printTotalTime(path);
printBusTransitCount(path);
printSubwayTransitCount(path);
printFirstStartStation(path);
printLastEndStation(path);
if (path.pathType == 1) {
printSubwayStationCount(path);
} else if (path.pathType == 2) {
printBusStationCount(path);
} else {
printBusStationCount(path);
printSubwayStationCount(path);
}
}
function printSubPath(subPath) {
if (subPath.trafficType == 1) {
console.log("지하철이용");
console.log("이동거리 : ", subPath.distance);
console.log("이동 소요시간 : ", subPath.sectionTime);
console.log(subPath.stationCount, "개의 역 이동");
console.log(subPath.startName, "에서 승차");
//startX
//startY
console.log("승차역 id : ", subPath.startID);
console.log(subPath.endName, "에서 하차");
//endX
//endY
console.log("하차역 id : ", subPath.endID);
printSubwayLane(subPath);
printPassStopList(subPath);
} else if (subPath.trafficType == 2) {
console.log("버스 이용");
console.log("이동거리 : ", subPath.distance);
console.log("이동 소요시간 : ", subPath.sectionTime);
console.log("이동 정거장수 :", subPath.stationCount);
console.log(subPath.startName, "에서 승차");
console.log("승차 정류쟝 id : ", subPath.startID);
console.log(subPath.endName, "에서 하차");
console.log("하차 정류장 id : ", subPath.endID);
printBusLane(subPath);
printPassStopList(subPath);
} else {
console.log("도보 이용");
console.log("이동 거리 : ", subPath.distance);
console.log("이동 소요시간 : ", subPath.sectionTime);
}
}
function printBusNumber(lane) {
console.log("버스 번호 : ", lane.busNo);
}
function printBusID(lane) {
console.log("버스 id : ", lane.busID);
}
function printBusLane(subPath) {
console.log("===========Bus=lane============");
console.log(subPath.lane.length, "개의 버스 이용가능");
for (var i = 0; i < subPath.lane.length; i++) {
console.log(i + 1, "번째 버스")
printBusNumber(subPath.lane[i]);
printBusID(subPath.lane[i]);
console.log("-------------------------");
}
}
function printSubwayLane(subPath) {
console.log("===========Subway=lane============");
console.log(subPath.lane.length, "개의 지하철 이용가능");
for (var i = 0; i < subPath.lane.length; i++) {
console.log(i + 1, "번째 지하철")
console.log(subPath.lane[i]);
console.log("-------------------------");
}
}
function printStations(station) {
console.log(" || ");
console.log(station.index, "번째 정류쟝");
console.log("정류쟝 id:", station.stationID);//=======>>>>>>실시간 API가져오기!!!
console.log(station.stationName);
console.log(" || ");
}
function printPassStopList(subPath) {
console.log("=====경로 확인=======");
for (var i = 0; i < subPath.passStopList.stations.length; i++) {
printStations(subPath.passStopList.stations[i]);
}
}
function printTotalCount(result) {
console.log(result.totalCount, "개의 경로 존재");
}
function printTrainCount(result) {
console.log("============기 차 이 용=================")
console.log("기차 탐색 결과 개수 : ", result.trainRequest.count);
}
function printOBJ(obj) {
console.log("출발역 :", obj.startSTN, ",id :", obj.startID);
//obj.SX
//obj.SY
console.log("도착역 :", obj.endSTN, ", id :", obj.endID);
//obj.EX
//obj.EY
console.log(obj.trainType);
//obj.trainCode
//obj.mapOBJ
console.log("소요 시간 :", obj.time);
console.log("요금 :", obj.payment);
}
function printExBusCount(result) {
console.log("==========고 속 버 스 이 용===========")
console.log("고속 버스 탐색 결과 개수 : ", result.exBusRequest.count);
}
function printOutBusCount(result) {
console.log("==========시 외 버 스 이 용===========")
console.log("시외 버스 탐색 결과 개수 : ", result.outBusRequest.count);
}
function searchPubTransPathAJAX() {
console.log('hihihihih');
var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
var xhr = new XMLHttpRequest();
//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";
var SX = 127.077001; //경희대학교 우정원 x좌표
var SY = 37.246214;//경희대학교 우정원 y좌표
var EX = 126.999472;//영통역 x좌표
var EY = 37.266670;//영통역 y좌표
var apiKey = "%2B6RMVoSKSHcru1NjEu194wRELD7wnalJG7JDY0mc2AE";
var url = "https://api.odsay.com/v1/api/searchPubTransPath?SX=" + SX + "&SY=" + SY + "&EX=" + EX + "&EY=" + EY + "&apiKey=" + apiKey;
xhr.open("GET", url, true);
xhr.send();
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var result = JSON.parse(xhr.responseText);
//console.log(xhr.responseText);
if (result.result.searchType == 0) { //한 도시내에서 이동
var totalPathSummary = new Object();//json 객체로 저장
totalPathSummary.searchType = result.result.searchType;
totalPathSummary.busCount = result.result.busCount;
totalPathSummary.subwayCount = result.result.subwayCount;
totalPathSummary.pointDistance = result.result.pointDistance;
totalPathSummary = JSON.stringify(totalPathSummary);
//console.log(totalPathSummary);
console.log("도시내 이동");
printBusCount(result);
printSubwayCount(result);
printSubwayBusCount(result);
printPointDistance(result);
var pathList = new Array();
for (var i = 0; i < result.result.path.length; i++) {
console.log("-----------------new 경로------------------------------");
console.log(i + 1, "번째 경로");
var path = new Object();
path.pathType = result.result.path[i].pathType;
path.info = result.result.path[i].info;
path.subPathList = new Array();
printPath(result.result.path[i].info);
for (var j = 0; j < result.result.path[i].subPath.length; j++) {
console.log("---------------");
var subPath = new Object();
subPath = result.result.path[i].subPath;
path.subPathList.push(subPath);
printSubPath(result.result.path[i].subPath[j]);
}
pathList.push(path);
console.log("--------------------경로 끝---------------------------");
}
pathList = JSON.stringify(pathList);
//console.log(pathList);
} else if (result.result.searchType == 1) {//도시간 이동
//console.log(result.result);
console.log("도시 간 이동");
var totalPathSummary = new Object();
totalPathSummary.startCityName = result.result.startCityName;
totalPathSummary.startCID = result.result.startCID;
totalPathSummary.endCityName = result.result.endCityName;
totalPathSummary.endCID = result.result.endCID;
totalPathSummary.pointDistance = result.result.pointDistance;
totalPathSummary.totalCount = result.result.totalCount;
totalPathSummary = JSON.stringify(totalPathSummary);
//console.log(totalPathSummary);
m
console.log("출발 도시:", result.result.startCityName);
console.log("도착 도시:", result.result.endCityName);
printPointDistance(result.result);
printTotalCount(result.result);
printTrainCount(result.result);//기차 이용
var trainList = new Array();//기차이용
for (var i = 0; i < result.result.trainRequest.count; i++) {
var OBJ = new Object();
OBJ = result.result.trainRequest.OBJ[i];
OBJList.push(OBJ);
console.log("============", i + 1, "============");
printOBJ(result.result.trainRequest.OBJ[i]);
}
trainList = JSON.stringify(trainList);
var exBusList = new Array();
printExBusCount(result.result); //고속버스 이용
for (var i = 0; i < result.result.exBusRequest.count; i++) {
var OBJ = new Object();
OBJ = result.result.exBusRequest.OBJ[i];
OBJList.push(OBJ);
console.log("============", i + 1, "============");
printOBJ(result.result.exBusRequest.OBJ[i]);
}
exBusList = JSON.stringify(exBusList);
var outBusList = new Array();
printOutBusCount(result.result);//시외 버스 이용
for (var i = 0; i < result.result.outBusRequest.count; i++) {
var OBJ = new Object();
OBJ = result.result.outBusRequest.OBJ[i];
outBusList.push(OBJ);
console.log("============", i + 1, "============");
printOBJ(result.result.outBusRequest.OBJ[i]);
}
outBusList = JSON.stringify(outBusList);
}
}
};
}
module.exports = {searchPubTransPathAJAX};
......@@ -2587,9 +2587,9 @@
}
},
"needle": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/needle/-/needle-2.4.1.tgz",
"integrity": "sha512-x/gi6ijr4B7fwl6WYL9FwlCvRQKGlUNvnceho8wxkwXqN8jvVmmmATTmZPRRG7b/yC1eode26C2HO9jl78Du9g==",
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/needle/-/needle-2.5.0.tgz",
"integrity": "sha512-o/qITSDR0JCyCKEQ1/1bnUXMmznxabbwi/Y4WwJElf+evwJNFNwIDMCCt5IigFVxgeGBJESLohGtIS9gEzo1fA==",
"requires": {
"debug": "^3.2.6",
"iconv-lite": "^0.4.4",
......@@ -4428,6 +4428,11 @@
"resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-3.0.0.tgz",
"integrity": "sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ="
},
"xmlhttprequest": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz",
"integrity": "sha1-Z/4HXFwk/vOfnWX197f+dRcZaPw="
},
"xmlhttprequest-ssl": {
"version": "1.5.5",
"resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz",
......
......@@ -30,6 +30,7 @@
"pug": "2.0.0-beta11",
"sequelize": "^5.21.5",
"sequelize-cli": "^5.5.1",
"socket.io": "^2.3.0"
"socket.io": "^2.3.0",
"xmlhttprequest": "^1.8.0"
}
}
......
......@@ -4,9 +4,10 @@ const bcrypt = require('bcrypt');
const passport = require('passport');
const {isLoggedIn, isNotLoggedIn} = require("./middleware");
const models = require('../models/index');
const {searchPubTransPathAJAX} = require('../crawling');
router.get('/loadMe', isLoggedIn, (req, res, next) => {
console.log('loadMe요청옴', req.user);
// console.log('loadMe요청옴', req.user);
return res.json({user: req.user});
});
......@@ -113,4 +114,8 @@ router.get('/logout', (req, res, next) => {
return res.send();
});
router.get('/test', (req, res, next) => {
searchPubTransPathAJAX();
});
module.exports = router;
\ No newline at end of file
......