/** * Class: OpenMap * * 오픈맵 기본 설정 */ var OpenMap = OpenMap || {}; /** * APIConstant: OpenMap.Layer * * {Object} */ OpenMap.Layer = OpenMap.Layer || {}; /** * APIConstant: OpenMap.DataSource * * {Object} */ OpenMap.DataSource = OpenMap.DataSource || {}; OpenMap.Config = { distUrl : 'openmap', imgBaseUrl : '/api/v1/svg/', imgBaseUrl2 : 'images/', legendUrl : 'openmap', layerPropertyUrl : '/api/v1/lc/?q=get&layer=', alterLayerPropertyUrl : '/api/v1/lc/?q=alter&layer=', createLayerPropertyUrl : '/api/v1/lc/?q=create', dropLayerPropertyUrl : '/api/v1/lc/?q=drop&layer=', getDataSourceUrl : 'dc/?q=get&ds=', alterDataSourceUrl : 'dc/?q=alter&ds=', createDataSourceUrl : 'dc/?q=create', dropDataSourceUrl : 'dc/?q=drop&ds=', openmapPrintUrl : Globals.urls.rmLayerPrint, openmapPrintImageUrl : Globals.urls.rmLayerPrint + '?printId=', defaultSiteDomain : 'http://localhost:8080', // 운영기에 반영할때는 운영기에 맞게 설정 // defaultBaseLayerFormatZ : 'L%d', // defaultBaseLayerFormatY : 'R%08x', // defaultBaseLayerFormatX : 'C%08x', flowPopUrl : Globals.urls.rmFlowpop, simplifyTolerance : 50, layerListUrl : '/api/v1/info/?q=layerlist', geoProcUrl : '/api/v1/geoprocess', colorRampUrl : '/api/v1/colorramp/', clusterUrl : 'openmap', dynamicUrl : [ Globals.urls.rmLayer + '?t=G&zoom=${z}&y=${y}&x=${x}' ], // currentBaseMapsSpec : "openmate" currentBaseMapsSpec : "vworld" }; //지도 입출력 좌표계 설정 (구글 좌표계(통칭), WGS84 경위도) var inout_options = { 'internalProjection' : new OpenLayers.Projection("EPSG:900913"), 'externalProjection' : new OpenLayers.Projection("EPSG:4326") // 'externalProjection' : new OpenLayers.Projection("OPENMATE") }; //서버통신 포맷 var formats = { wkt : new OpenLayers.Format.WKT(inout_options), geojson : new OpenLayers.Format.GeoJSON(inout_options), kml : new OpenLayers.Format.KML(inout_options), json : new OpenLayers.Format.JSON(inout_options) }; // 서버 통신을 위한 객체 직렬화 function serializeGeom(obj) { var str = ""; var cObj = obj.clone(); cObj.transform(inout_options['internalProjection'], inout_options['externalProjection']); str = cObj.toString(); // console.log("serialized " + str); return str; }; // 지도 표현을 위한 객체 역직렬화 function deserialize(jsonData) { // console.log("received data " + jsonData.toString()); var type = "wkt"; // select type var features = formats[type].read(jsonData); if (features) { // var plural = (features.length > 1) ? 's' : ''; vectorLayer.addFeatures(features); // vectorLayer.removeFeatures(selectedGeomArray); } else { alert('Bad input ' + type); } }; // 지도 표현을 위한 객체 역직렬화 function deserializeWktArray(jsonData) { // console.log("received data " + jsonData.toString()); var arr = formats["json"].read(jsonData); for (var i = 0; i < arr.length; i++) { var type = "wkt"; // select type var features = formats[type].read(arr[i]); if (features) { vectorLayer.addFeatures(features); } else { alert('Bad input ' + type); } } // vectorLayer.removeFeatures(selectedGeomArray); }; var console = console || { log : function() { return; } }; OpenMap.Config.baseMapsSpecs = function() { /** * proj4js.js 파일에 설정된 좌표계 * 주석 제거하지 말고 참고만 할 것 * Proj4js.defs = { * 'WGS84' : "+title=long/lat:WGS84 +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees", * 'EPSG:4326' : "+title=long/lat:WGS84 +proj=longlat +a=6378137.0 +b=6356752.31424518 +ellps=WGS84 +datum=WGS84 +units=degrees", * 'EPSG:4269' : "+title=long/lat:NAD83 +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees", * 'EPSG:3785' : "+title= Google Mercator +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs" * }; * Proj4js.defs['GOOGLE'] = Proj4js.defs['EPSG:3785']; * Proj4js.defs['EPSG:900913'] = Proj4js.defs['EPSG:3785']; * Proj4js.defs['EPSG:102113'] = Proj4js.defs['EPSG:3785']; */ Proj4js.defs["KATEC"] = "+proj=tmerc +lat_0=38.0 +lon_0=128.0 +x_0=400000.0 +y_0=600000.0 +k=0.9999 +ellps=bessel +a=6377397.155 +b=6356078.9628181886 +units=m +towgs84=-115.80,474.99,674.11,1.16,-2.31,-1.63,6.43"; Proj4js.defs["OPENMATE"] = Proj4js.defs["KATEC"]; // Proj4js.defs["EPSG:5181"] = "+proj=tmerc +lat_0=38.0 +lon_0=127.0 +k=1 +x_0=200000 +y_0=500000 +ellps=GRS80 +units=m +no_defs"; // 중부원점(GRS80) // Proj4js.defs["EPSG:5181"] = "+proj=tmerc +lat_0=38.0 +lon_0=127.0 +k=1 +x_0=200000 +y_0=500000 +ellps=GRS80 +units=m"; Proj4js.defs["EPSG:5181"] = "+proj=tmerc +lat_0=38.0 +lon_0=127.0 +k=1 +x_0=200000 +y_0=500000 +ellps=WGS84"; Proj4js.defs["DAUM"] = Proj4js.defs["EPSG:5181"]; Proj4js.defs["EPSG:5179"] = "+proj=tmerc +lat_0=38 +lon_0=127.5 +k=0.9996 +x_0=1000000 +y_0=2000000 +ellps=GRS80 +units=m +no_defs"; Proj4js.defs["KT"] = Proj4js.defs["EPSG:5179"]; var vworld = { spec : { resolutions : [ /*156543.0339, 78271.51695, 39135.758475, 19567.8792375, 9783.93961875, 4891.969809375, 2445.9849046875,*/ /*1222.99245234375,*/ 611.496226171875, 305.7481130859375, 152.87405654296876, 76.43702827148438, 38.21851413574219, 19.109257067871095, 9.554628533935547, 4.777314266967774, 2.388657133483887, 1.1943285667419434, 0.5971642833709717 ], // tileOrigin : new OpenLayers.LonLat(-20037508.342787001, 20037508.342787001), // maxExtent : new OpenLayers.Bounds(13814748.805522, 3868787.29756, 14694172.782667, 4678789.7959737), // initBounds : new OpenLayers.Bounds(120.9375, 31.95216223802497, 132.1875, 43.068), initBounds : new OpenLayers.Bounds(13462700.917811522, 3757032.814272987, 14715045.189235851, 5322327.874481018), zoom : 0, zoomOffset : 8, dataProjection : new OpenLayers.Projection("OPENMATE"), projection : new OpenLayers.Projection("EPSG:900913"), min_level : 8, max_level : 18, // numZoomLevels : 12, imgUrl : [ vworldUrls.base + "/${z}/${x}/${y}.png" ], dynamicUrl : [ Globals.urls.rmLayer + '?t=G&zoom=${z}&y=${y}&x=${x}' ] }, getXYZ : function(bounds) { // console.log(this); // TODO: remove bounds = this.adjustBounds(bounds); var res = this.map.getResolution(); var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w)); var y = Math.round((this.maxExtent.top - bounds.top) / (res * this.tileSize.h)); var z = this.map.getZoom() + this.zoomOffset; var limit = Math.pow(2, z); // console.log("x=" + x); // TODO: remove // console.log("y=" + y); // TODO: remove // console.log("z=" + z); // TODO: remove // console.log("limit=" + limit); // TODO: remove if (y < 0 || y >= limit) { // console.log("aa"); // TODO: remove return null; } else { x = ((x % limit) + limit) % limit; // console.log(this.initBounds); // TODO: remove if (this.initBounds.intersectsBounds(bounds)) { if (z >= this.min_level && z <= this.max_level) { return { x : x, y : y, z : z }; } else if (z > this.max_level) { var n = z - this.max_level; var z2 = z - n; var nsize = 256 * Math.pow(2, n); var x = Math.round((bounds.left - this.maxExtent.left) / (res * nsize)); var y = Math.round((this.maxExtent.top - bounds.top) / (res * nsize)); x = ((x % limit) + limit) % limit; return { x : x, y : y, z : z2 }; } else { // console.log("bb"); // TODO: remove return null; } } else { // console.log("cc"); // TODO: remove return null; } } }, getURL : function(bounds) { var xyz = this.getXYZ(bounds); // console.log(xyz); // TODO: remove if (xyz == null) { return vworldUrlsExt.blankimage; } else { var serverIndex = Math.abs((xyz.x + xyz.y) % this.url.length); if (serverIndex < 0) { serverIndex = 0; } else if (serverIndex > 3) { serverIndex = 3; } var xyzUrl = OpenLayers.String.format(this.url[serverIndex], xyz); // console.log(xyzUrl); // TODO: remove return xyzUrl; } } }; // vworld var vworld_sat = $.extend(true, {}, vworld); vworld_sat.spec.imgUrl = [ vworldUrls.raster + "/${z}/${x}/${y}.jpeg" ]; vworld_sat.spec.additionalLayers = [ { name : 'VWorld Hybrid', url : [ vworldUrls.hybrid + "/${z}/${x}/${y}.png" ] } ]; var openmate = { spec : { resolutions : [ 1222.9924525624949, 611.49622628137968, 305.74811314055756, 152.87405657041106, 76.437028285073239, 38.21851414253662, 19.10925707126831, 9.5546285356341549, 4.7773142679493699, 2.3886571339746849, 1.1943285668550503, 0.59716428355981721, 0.29858214177990860 ], tileOrigin : new OpenLayers.LonLat(-20037508.342787001, 20037508.342787001), maxExtent : new OpenLayers.Bounds(13814748.805522, 3868787.29756, 14694172.782667, 4678789.7959737), zoomOffset : 7, dataProjection : new OpenLayers.Projection("OPENMATE"), projection : new OpenLayers.Projection("EPSG:900913"), numZoomLevels : 13, imgUrl : [ 'http://wmap0.openmate.com:8081/tilemap/${z}/${y}/${x}.png', 'http://wmap1.openmate.com:8081/tilemap/${z}/${y}/${x}.png', 'http://wmap2.openmate.com:8081/tilemap/${z}/${y}/${x}.png', 'http://wmap3.openmate.com:8081/tilemap/${z}/${y}/${x}.png' ], dynamicUrl : [ Globals.urls.rmLayer + '?t=G&zoom=${z}&y=${y}&x=${x}' ] }, getXYZ : function(bounds) { var xyz = {}; var res = this.getServerResolution(); var tileOrigin = this.tileOrigin; var originTileX = (tileOrigin.lon + (res * OpenLayers.Map.TILE_WIDTH / 2)); var originTileY = (tileOrigin.lat - (res * OpenLayers.Map.TILE_HEIGHT / 2)); var center = bounds.getCenterLonLat(); xyz.x = (Math.round(Math.abs((center.lon - originTileX) / (res * OpenLayers.Map.TILE_WIDTH)))); xyz.y = (Math.round(Math.abs((originTileY - center.lat) / (res * OpenLayers.Map.TILE_HEIGHT)))); xyz.z = this.getServerZoom(); return xyz; }, getURL : function(bounds) { if (!this.zeroPad) { this.zeroPad = function(num, len, radix) { var str = num.toString(radix || 10); while (str.length < len) { str = "0" + str; } return str; }; } var xyz = this.getXYZ(bounds); var serverIndex = (xyz.x + xyz.y) % this.imgUrl.length; xyz.x = 'C' + this.zeroPad(xyz.x, 8, 16); xyz.y = 'R' + this.zeroPad(xyz.y, 8, 16); xyz.z = 'L' + this.zeroPad(xyz.z, 2, 10); return OpenLayers.String.format(this.imgUrl[serverIndex], xyz); }, // 줌 레벨별 클러스터 영역 getZoomCluster : function(z) { z = z || this.getServerZoom(); if (z > 16) { return 'PT'; //포인트 17, 18 } else if (z > 14) { return 'BL'; //블럭 15,16 } else if (z > 11) { return 'H4'; //행정동 14,13,12 } else if (z > 9) { return 'H2'; //시군구 11,10 } else { return 'BR'; //지국 9,8,7 } } }; // openmate return { vworld : vworld, vworld_sat : vworld_sat, openmate : openmate }; }();