문제 1 - 한번에 받아오는 geojson to postgis
this.FetchAllTrajNodeData = function(cbOnFetchFinished) { this.DebugLog("FetchAllTrajNodeData called. Fetching traj data from stryx server..") var url = this.apiServerOrigin + 'api/rounds_data/all' $.ajax({ url: url, type: 'GET' }).done(function(data) { this.DebugLog("Round data fetched") // this.DebugLog(data) cbOnFetchFinished(data) }.bind(this)).fail(function(data) { this.DebugLog("fail") }.bind(this)).always(function() { }) }
이부분 server 에서 받아오는데 그게 아니라
geoserver에서 받아오는게 더 좋을듯 구현된 게 있으니까
tmpStpano.FetchAllTrajNodeData(function (features) { console.log("(simulated) node fetched from server") let table = document.getElementById("trajTable") let node_idx = 0 for (let feature of features) { let tr = document.createElement("tr") let th_idx = document.createElement("td") let aTag = document.createElement('a') aTag.setAttribute('href', '#') aTag.textContent = (++node_idx).toString() aTag.style.fontWeight = "bold" th_idx.appendChild(aTag) th_idx.onclick = function(pvrid) { console.log("Panorama moved!") tmpStpano.AvatarMove({ type: 'id', nodeid: pvrid }) }.bind(null, feature.get('pvrid')) // Table Edit tr.appendChild(th_idx) let td_stat = document.createElement("td") td_stat.appendChild(document.createTextNode(feature.get('lon'))) tr.appendChild(td_stat) let td_Y = document.createElement("td") td_Y.appendChild(document.createTextNode(feature.get('lat'))) tr.appendChild(td_Y) let td_Head = document.createElement("td") td_Head.appendChild(document.createTextNode(feature.get('heading'))) tr.appendChild(td_Head) // let td_JID = document.createElement("td") // td_JID.appendChild(document.createTextNode(journeyID)) // tr.appendChild(td_JID) let td_Pvr = document.createElement("td") td_Pvr.appendChild(document.createTextNode(feature.get('pvrid'))) tr.appendChild(td_Pvr) table.tBodies[0].appendChild(tr) } })
this.FetchAllTrajNodeData = function(cbOnFetchFinished) { this.DebugLog("FetchAllTrajNodeData called. Fetching traj data from stryx server..") fetch( DFT_FEATURE_URL, { method: 'GET', mode: 'cors' } ) .then(response => { return response.json() }) .then(json => { let features = new ol.format.GeoJSON().readFeatures(json) cbOnFetchFinished(features) }) }
요런 식으로 해주면 무치게

받아오기 완료~
문제 2 - panorama 위해서 pvrid 다른 부분 연결해줘야함 db table 추가
- 일단 시퀄라이저 모델에 추가
/* jshint indent: 1 */ module.exports = (sequelize, DataTypes) => { return sequelize.define('pvr', { pvrid: { type: DataTypes.INTEGER(10).UNSIGNED, allowNull: false, primaryKey: true, autoIncrement: true }, north: { type: DataTypes.DOUBLE, allowNull: false, }, seq: { type: DataTypes.INTEGER(5), allowNull: false, }, sourcepath: { type: DataTypes.STRING(400), allowNull: false }, latitude: { type: DataTypes.DOUBLE, allowNull: false, }, longitude: { type: DataTypes.DOUBLE, allowNull: false, } }, { tableName: 'pvr' }) }

exports.getPanoxml = async(req, res, next) => { try { let builder = new xml2js.Builder() const node_id = req.params.node_id const serverHost = req.protocol + "://" + req.get("Host") let tilePrepender = serverHost + "/api/pano/tile/" + node_id let previewPrepender = serverHost + "/api/pano/preview/" + node_id getNodeInfo(node_id) .then(row => { let xmlFilePath = row.round_path + '/' + TILE_FOLDER + row.seq + '_Panorama/pano.xml' xmlFilePath = xmlFilePath.replace(/\//gi, '\\') let xx = fs.readFileSync(xmlFilePath) console.log('xml path', xmlFilePath) res.set('Content-Type', 'text/xml') fs.readFile(xmlFilePath, 'utf8', function(err, data) { let strXML = data xml2js.parseString(strXML, function(err, parsedJson) { parsedJson.krpano.preview[0].$.url = parsedJson.krpano.preview[0].$.url.replace("images/preview.jpg", previewPrepender) parsedJson.krpano.image[0].level.forEach(level => { level.cube[0].$.url = level.cube[0].$.url.replace("images", tilePrepender) }) let strXmlGen = builder.buildObject(parsedJson) console.log(strXmlGen) res.send(strXmlGen) }) }) }) } catch (error) { console.error(error) next(error) } }
계속되는 no such file...
JavaScript에서 string을 replaceAll 하고싶을 때
javascript에서 스트링을 replace할때 당황스러웠던 적이 있었다. 12> "javascript".replace("a","b")'jbvascript' 저렇게 앞의 한글자만 replace를 해주기때문이다.어떻게하면 깔끔하게 할 수 있을지 구글링하다보니 역시 답이 나왔다. 정규식을 이용해서 replace를 하면되는데 12> "javascri
https://tech.songyunseop.com/post/2016/09/javascript-replace-all/

- regex로 replace all 하는 법도 알아냈는데 / 인지 \ 인지는 상관없이 안되네
문제 3. relation upload 하기
쥐리게 exist round 이용
안하면 시간 몇시간 넘게 걸리는듯 비선형적 time complextity
def rel_upload(src_engine, dst_engine, src_db_conn, exist_round): # Relation SQL Query - from, to, pan, sourcepath filtered_rel = pd.DataFrame({}) for round in exist_round: sql = ('SELECT r.pvrid AS \'from\', r.relationid AS \'to\', ' 'r.relationpan AS pan FROM relation AS r ' 'LEFT JOIN pvr ON r.pvrid = pvr.pvrid ' f'where pvr.sourcepath = \'{round}\'') df_rel = pd.read_sql_query( sql=sql, con=src_db_conn) logging.info(io.blue(df_rel.head())) filtered_rel = filtered_rel.append(df_rel, ignore_index=True) logging.info("head df_rel") logging.info(io.blue(filtered_rel.head())) return filtered_reldef rel_upload(src_engine, dst_engine, src_db_conn, exist_round): # Relation SQL Query - from, to, pan, sourcepath filtered_rel = pd.DataFrame({}) for round in exist_round: sql = ('SELECT r.pvrid AS \'from\', r.relationid AS \'to\', ' 'r.relationpan AS pan FROM relation AS r ' 'LEFT JOIN pvr ON r.pvrid = pvr.pvrid ' f'where pvr.sourcepath = \'{round}\'') df_rel = pd.read_sql_query( sql=sql, con=src_db_conn) logging.info(io.blue(df_rel.head())) filtered_rel = filtered_rel.append(df_rel, ignore_index=True) logging.info("head df_rel") logging.info(io.blue(filtered_rel.head())) return filtered_rel
Python| Pandas dataframe.append() - GeeksforGeeks
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas dataframe.append() function is used to append rows of other dataframe to the end of the given dataframe, returning a new dataframe object.
https://www.geeksforgeeks.org/python-pandas-dataframe-append/

append 도 그냥 return 만 하고 자동 업데이트 안해서 좀 뻘짓했다..
pandas 자체 성격이 그런듯
Pythonic way to create a long multi-line string
I have a very long query. I would like to split it in several lines in Python. A way to do it in JavaScript would be using several sentences and joining them with a + operator (I know, maybe it's n...
https://stackoverflow.com/questions/10660435/pythonic-way-to-create-a-long-multi-line-string
sql = ('SELECT r.pvrid AS \'from\', r.relationid AS \'to\', ' 'r.relationpan AS pan FROM relation AS r ' 'LEFT JOIN pvr ON r.pvrid = pvr.pvrid ' f'where pvr.sourcepath = \'{round}\'')
이런식 파이썬... 점점 진화?
How to split comma separated string using JavaScript?
I want to split a comma separated string with JavaScript. How?
https://stackoverflow.com/questions/5269856/how-to-split-comma-separated-string-using-javascript
보내는 곳
router.get("/nearnode/:node_id", function(req, res, next){ let from = req.params.node_id models.relation.findAll({ where: { from: from } }).then(result => { res.json(result) }).catch(err => { console.log(err) }) })
그리고 받아오는 곳
done(function (data) { this.DebugLog(data) var nearNodeList = data nearNodeList.forEach((nearNode) => { let relationTrajnodeId = nearNode.to let relationPan = nearNode.pan let hotspotAth = 0 heading = getDrawLayer(map).selected.get('heading') hotspotAth = heading + relationPan this.GetKrpanoInstance().call("addhotspot(pois"+ relationTrajnodeId +")") this.GetKrpanoInstance().call('set(hotspot[pois'+ relationTrajnodeId +'].url, '+this.apiServerOrigin+'static/vtourskin_hotspot.png)') this.GetKrpanoInstance().call('set(hotspot[pois'+ relationTrajnodeId +'].ath, '+ hotspotAth +')') this.GetKrpanoInstance().call('set(hotspot[pois'+ relationTrajnodeId +'].atv, 20)') this.GetKrpanoInstance().call('set(hotspot[pois'+ relationTrajnodeId +'].width, 64)') this.GetKrpanoInstance().call('set(hotspot[pois'+ relationTrajnodeId +'].height, 64)') this.GetKrpanoInstance().call('set(hotspot[pois'+ relationTrajnodeId +'].distorted, true)') this.GetKrpanoInstance().set('hotspot[pois'+ relationTrajnodeId +'].onclick', function(relationTrajnodeId) { this.DebugLog("Heading: "+ hotspotAth) let currentHlookat = this.GetKrpanoInstance().get("view.hlookat") let currentVlookat = this.GetKrpanoInstance().get("view.vlookat") let relationTrajnode = this.FetchTrajnodeById(relationTrajnodeId) let relationHeading = relationTrajnode.get('heading') // Change Selected changeFeaturebyID(relationTrajnodeId, map) this.AvatarMove({ type: 'id', journeyid: 1, nodeid: relationTrajnodeId, hlookat: currentHlookat, vlookat: currentVlookat, heading: relationHeading }) }.bind(tmpStPano, relationTrajnodeId))

Seonglae Cho