dx.vectormaputils.js 7.5 KB
Newer Older
eddie.woo's avatar
eddie.woo committed
1 2 3 4 5 6 7 8 9
/*!
* DevExtreme (dx.vectormaputils.js)
* Version: 17.1.5
* Build date: Tue Aug 01 2017
*
* Copyright (c) 2012 - 2017 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
"use strict";!function(n){function e(){}function t(n){return n}function r(n){return"function"==typeof n}function o(n){var e,t=X(n),r=0;return e={pos:function(){return r},skip:function(n){return r+=n,e},ui8arr:function(n){var t=0,r=[];for(r.length=n;t<n;++t)r[t]=e.ui8();return r},ui8:function(){var n=q(t,r);return r+=1,n},ui16LE:function(){var n=F(t,r);return r+=2,n},ui32LE:function(){var n=H(t,r);return r+=4,n},ui32BE:function(){var n=J(t,r);return r+=4,n},f64LE:function(){var n=V(t,r);return r+=8,n}}}function i(n,e,t){var r,i=n[0]?f(o(n[0]),t):{},s=n[1]?_(o(n[1]),t):{},a=u(i.shapes||[],s.records||[],e);return a.length?(r={type:"FeatureCollection",features:a},r.bbox=i.bBox):r=null,r}function u(n,e,t){var r,o,i=[],u=i.length=u=Math.max(n.length,e.length);for(r=0;r<u;++r)o=n[r]||{},i[r]={type:"Feature",geometry:{type:o.geoJSON_type||null,coordinates:o.coordinates?t(o.coordinates):[]},properties:e[r]||null};return i}function s(n){function e(n){return Math.round(n*r)/r}function t(n){return n.map(n[0].length?t:e)}var r=Number("1E"+n);return t}function a(n){return n=n||{},["shp","dbf"].map(function(e){return function(t){n.substr?(e="."+e,Y(n+(n.substr(-e.length).toLowerCase()===e?"":e),function(n,e){t(n,e)})):t(null,n[e]||null)}})}function c(n,o,u){var c;return l(a(n),function(n,a){u=r(o)&&o||r(u)&&u||e,o=!r(o)&&o||{};var l=[];n.forEach(function(n){n&&l.push(n)}),c=i(a,o.precision>=0?s(o.precision):t,l),u(c,l.length?l:null)}),c}function l(n,e){function t(){--i,0!==i||u||e(r,o)}var r=[],o=[],i=1,u=!0;n.forEach(function(n,e){++i,n(function(n,i){r[e]=n,o[e]=i,t()})}),u=!1,t()}function f(n,e){var t,r,o,i,u=[];try{t=new Date,o=x(n)}catch(n){return void e.push("shp: header parsing error: "+n.message+" / "+n.description)}9994!==o.fileCode&&e.push("shp: file code: "+o.fileCode+" / expected: 9994"),1e3!==o.version&&e.push("shp: file version: "+o.version+" / expected: 1000");try{for(;n.pos()<o.fileLength&&(i=N(n,o.type,e));)u.push(i);n.pos()!==o.fileLength&&e.push("shp: file length: "+o.fileLength+" / actual: "+n.pos()),r=new Date}catch(n){e.push("shp: records parsing error: "+n.message+" / "+n.description)}finally{return{bBox:o.bBox_XY,type:o.shapeType,shapes:u,errors:e,time:r-t}}}function p(n,e){e.coordinates=k(n,1)[0]}function h(n,e){var t,r=w(n),o=M(n),i=M(n),u=B(n,o),s=k(n,i),a=[];for(a.length=o,t=0;t<o;++t)a[t]=s.slice(u[t],u[t+1]||i);e.bBox=r,e.coordinates=a}function g(n,e){e.bBox=w(n),e.coordinates=k(n,M(n))}function d(n,e){e.coordinates=k(n,1)[0],e.coordinates.push(E(n,1)[0])}function y(n,e){var t=w(n),r=M(n),o=k(n,r),i=D(n),u=E(n,r);e.bBox=t,e.mBox=i,e.coordinates=C(o,u,r)}function v(n,e){var t,r,o,i=w(n),u=M(n),s=M(n),a=B(n,u),c=k(n,s),l=D(n),f=E(n,s),p=[];for(p.length=u,t=0;t<u;++t)r=a[t],o=a[t+1]||s,p[t]=C(c.slice(r,o),f.slice(r,o),o-r);e.bBox=i,e.mBox=l,e.coordinates=p}function b(n,e){e.coordinates=k(n,1)[0],e.push(E(n,1)[0],E(n,1)[0])}function m(n,e){var t=w(n),r=M(n),o=k(n,r),i=D(n),u=E(n,r),s=D(n),a=E(n,r);e.bBox=t,e.zBox=i,e.mBox=s,e.coordinates=Z(o,u,a,r)}function P(n,e){var t,r,o,i=w(n),u=M(n),s=M(n),a=B(n,u),c=k(n,s),l=D(n),f=E(n,s),p=D(n),h=E(n,s),g=[];for(g.length=u,t=0;t<u;++t)r=a[t],o=a[t+1]||s,g[t]=Z(c.slice(r,o),f.slice(r,o),h.slice(r,o),o-r);e.bBox=i,e.zBox=l,e.mBox=p,e.coordinates=g}function L(n,e){var t,r,o,i=w(n),u=M(n),s=M(n),a=B(n,u),c=B(n,u),l=k(n,s),f=D(n),p=E(n,s),h=D(n),g=[];for(g.length=u,t=0;t<u;++t)r=a[t],o=a[t+1]||s,g[t]=Z(l.slice(r,o),p.slice(r,o),mValues.slice(r,o),o-r);e.bBox=i,e.zBox=f,e.mBox=h,e.types=c,e.coordinates=g}function x(n){var e={};return e.fileCode=n.ui32BE(),n.skip(20),e.fileLength=n.ui32BE()<<1,e.version=n.ui32LE(),e.type_number=n.ui32LE(),e.type=I[e.type_number],e.bBox_XY=w(n),e.bBox_ZM=k(n,2),e}function M(n){return n.ui32LE()}function B(n,e){var t,r=[];for(r.length=e,t=0;t<e;++t)r[t]=M(n);return r}function E(n,e){var t,r=[];for(r.length=e,t=0;t<e;++t)r[t]=n.f64LE();return r}function w(n){return E(n,4)}function D(n){return[n.f64LE(),n.f64LE()]}function k(n,e){var t,r=[];for(r.length=e,t=0;t<e;++t)r[t]=D(n);return r}function C(n,e,t){var r,o=[];for(o.length=t,r=0;r<t;++r)o[r]=[n[r][0],n[r][1],e[r]];return o}function Z(n,e,t,r){var o,i=[];for(i.length=r,o=0;o<r;++o)i[o]=[n[o][0],n[o][1],e[o],t[o]];return i}function N(n,e,t){var r={number:n.ui32BE()},o=n.ui32BE()<<1,i=n.pos(),u=n.ui32LE();return r.type_number=u,r.type=I[u],r.geoJSON_type=W[r.type],r.type?(r.type!==e&&t.push("shp: shape #"+r.number+" type: "+r.type+" / expected: "+e),K[u](n,r),i=n.pos()-i,i!==o&&t.push("shp: shape #"+r.number+" length: "+o+" / actual: "+i)):(t.push("shp: shape #"+r.number+" type: "+u+" / unknown"),r=null),r}function _(n,e){var t,r,o,i,u;try{t=new Date,o=R(n,e),i=O(o,e),u=T(n,o.numberOfRecords,o.recordLength,i,e),r=new Date}catch(n){e.push("dbf: parsing error: "+n.message+" / "+n.description)}finally{return{records:u,errors:e,time:r-t}}}function R(n,e){var t,r,o={versionNumber:n.ui8(),lastUpdate:new Date(1900+n.ui8(),n.ui8()-1,n.ui8()),numberOfRecords:n.ui32LE(),headerLength:n.ui16LE(),recordLength:n.ui16LE(),fields:[]};for(n.skip(20),t=(o.headerLength-n.pos()-1)/32;t>0;--t)o.fields.push(U(n));return r=n.ui8(),13!==r&&e.push("dbf: header terminator: "+r+" / expected: 13"),o}function S(n,e){return $.apply(null,n.ui8arr(e))}function U(n){var e={name:S(n,11).replace(/\0*$/gi,""),type:$(n.ui8()),length:n.skip(4).ui8(),count:n.ui8()};return n.skip(14),e}function z(n,e){return n.skip(e),null}function O(n,e){var t,r,o=[],i=0,u=n.fields.length,s=0;for(i=0;i<u;++i)r=n.fields[i],t={name:r.name,parser:j[r.type],length:r.length},t.parser||(t.parser=z,e.push("dbf: field "+r.name+" type: "+r.type+" / unknown")),s+=r.length,o.push(t);return s+1!==n.recordLength&&e.push("dbf: record length: "+n.recordLength+" / actual: "+(s+1)),o}function T(n,e,t,r,o){var i,u,s,a,c,l=r.length,f=[];for(i=0;i<e;++i){for(a={},s=n.pos(),n.skip(1),u=0;u<l;++u)c=r[u],a[c.name]=c.parser(n,c.length);s=n.pos()-s,s!==t&&o.push("dbf: record #"+(i+1)+" length: "+t+" / actual: "+s),f.push(a)}return f}function X(n){return new DataView(n)}function q(n,e){return n.getUint8(e)}function F(n,e){return n.getUint16(e,!0)}function H(n,e){return n.getUint32(e,!0)}function J(n,e){return n.getUint32(e,!1)}function V(n,e){return n.getFloat64(e,!0)}function Y(n,e){var t=new XMLHttpRequest;t.onreadystatechange=function(){4===this.readyState&&("OK"===this.statusText?e(null,this.response):e(this.statusText,null))},t.open("GET",n),t.responseType="arraybuffer",t.setRequestHeader("X-Requested-With","XMLHttpRequest"),t.send(null)}var G=n.DevExpress=n.DevExpress||{};G=G.viz=G.viz||{},G=G.vectormaputils={},G.parse=c;var I={0:"Null",1:"Point",3:"PolyLine",5:"Polygon",8:"MultiPoint",11:"PointZ",13:"PolyLineZ",15:"PolygonZ",18:"MultiPointZ",21:"PointM",23:"PolyLineM",25:"PolygonM",28:"MultiPointM",31:"MultiPatch"},K={0:e,1:p,3:h,5:h,8:g,11:b,13:P,15:P,18:m,21:d,23:v,25:v,28:y,31:L},W={Null:"Null",Point:"Point",PolyLine:"MultiLineString",Polygon:"Polygon",MultiPoint:"MultiPoint",PointZ:"Point",PolyLineZ:"MultiLineString",PolygonZ:"Polygon",MultiPointZ:"MultiPoint",PointM:"Point",PolyLineM:"MultiLineString",PolygonM:"Polygon",MultiPointM:"MultiPoint",MultiPatch:"MultiPatch"},$=String.fromCharCode,j={C:function(n,e){var t=S(n,e);try{t=decodeURIComponent(escape(t))}catch(n){}return t.trim()},N:function(n,e){var t=S(n,e);return parseFloat(t,10)},D:function(n,e){var t=S(n,e);return new Date(t.substring(0,4),t.substring(4,6)-1,t.substring(6,8))}}}(window);