Custom Gis Application with Arcgis Javascript API with modern layouting
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

30 lines
14 KiB

// All material copyright Esri, All Rights Reserved, unless otherwise specified.
// See https://js.arcgis.com/4.30/esri/copyright.txt for details.
//>>built
define("exports ../../../Graphic ../../kernel ../support/errorsupport ../support/FeatureSet ../support/IdSet ../support/shared ../support/sqlUtils ../../../core/maybe ../../../core/sql/WhereClause ../../../geometry/SpatialReference".split(" "),function(q,z,A,p,B,u,n,m,C,r,D){class t{constructor(a){this.field=a;this.sqlRewritable=!1}postInitialization(a,b){}}class v extends t{constructor(a){super(a);this.sqlRewritable=!0}extractValue(a){return a.attributes[this.field.name]}rewriteSql(a){return{rewritten:this.sqlRewritable,
where:a}}}class x extends t{constructor(a,b,d){super(n.cloneField(a));this.originalField=a;this.sqlRewritable=!0;this.field.name=b;this.field.alias=d}rewriteSql(a,b){return{rewritten:this.sqlRewritable,where:m.reformulateWithoutField(a,this.field.name,this.originalField.name,b.getFieldsIndex())}}extractValue(a){return a.attributes[this.originalField.name]}}class k extends t{constructor(a,b,d){super(a);this.codefield=b;this.lkp=d;this.reverseLkp={};for(const e in d)this.reverseLkp[d[e]]=e;this.sqlRewritable=
!0}rewriteSql(a,b){const d=this.evaluateNodeToWhereClause(a.parseTree,n.FeatureServiceDatabaseType.Standardised,this.field.name,this.codefield instanceof r.WhereClause?m.toWhereClause(this.codefield,n.FeatureServiceDatabaseType.Standardised):this.codefield,a.parameters);return d.includes(k.BADNESS)?{rewritten:!1,where:a}:{rewritten:this.sqlRewritable,where:r.WhereClause.create(d,b._parent.getFieldsIndex(),b.dateFieldsTimeZoneDefaultUTC)}}evaluateNodeToWhereClause(a,b,d=null,e=null,c){var f;switch(a.type){case "interval":return m.convertIntervalToSql(this.evaluateNodeToWhereClause(a.value,
b,d,e,c),a.qualifier,a.op);case "case-expression":e=" CASE ";"simple"===a.format&&(e+=this.evaluateNodeToWhereClause(a.operand,b,d,k.BADNESS,c));for(f=0;f<a.clauses.length;f++)e+=" WHEN "+this.evaluateNodeToWhereClause(a.clauses[f].operand,b,d,k.BADNESS,c)+" THEN "+this.evaluateNodeToWhereClause(a.clauses[f].value,b,d,k.BADNESS,c);null!==a.else&&(e+=" ELSE "+this.evaluateNodeToWhereClause(a.else,b,d,k.BADNESS,c));return e+" END ";case "parameter":a=c[a.value.toLowerCase()];if("string"===typeof a)return"'"+
a.toString().replaceAll("'","''")+"'";if(n.isDate(a)||n.isLuxonDate(a))return m.makeSqlFromDateTimeParameter(a,b);if(n.isArcadeTime(a))return m.makeTimeString(a,b);if(n.isArcadeDate(a))return m.arcadeDateToSqlString(a,b);if(n.isArcadeDateOnly(a))return m.arcadeDateOnlyToSqlString(a,b);if(Array.isArray(a)){d=[];for(c=0;c<a.length;c++)"string"===typeof a[c]?d.push("'"+a[c].toString().replaceAll("'","''")+"'"):n.isDate(a[c])?d.push(m.makeSqlFromDateTimeParameter(a[c],b)):n.isLuxonDate(a[c])?d.push(m.makeSqlFromDateTimeParameter(a[c],
b)):n.isArcadeTime(a[c])?d.push(m.makeTimeString(a[c],b)):n.isArcadeDate(a[c])?d.push(m.arcadeDateToSqlString(a[c],b)):n.isArcadeDateOnly(a[c])?d.push(m.arcadeDateOnlyToSqlString(a[c],b)):d.push(a[c].toString());return d}return a.toString();case "expression-list":f=[];for(h of a.value)f.push(this.evaluateNodeToWhereClause(h,b,d,e,c));return f;case "unary-expression":return" ( NOT "+this.evaluateNodeToWhereClause(a.expr,b,d,k.BADNESS,c)+" ) ";case "binary-expression":switch(a.operator){case "AND":return" ("+
this.evaluateNodeToWhereClause(a.left,b,d,e,c)+" AND "+this.evaluateNodeToWhereClause(a.right,b,d,e,c)+") ";case "OR":return" ("+this.evaluateNodeToWhereClause(a.left,b,d,e,c)+" OR "+this.evaluateNodeToWhereClause(a.right,b,d,e,c)+") ";case "IS":if("null"!==a.right.type)throw new p.SqlError(p.SqlErrorCodes.UnsupportedIsRhs);return" ("+this.evaluateNodeToWhereClause(a.left,b,d,e,c)+" IS NULL )";case "ISNOT":if("null"!==a.right.type)throw new p.SqlError(p.SqlErrorCodes.UnsupportedIsRhs);return" ("+
this.evaluateNodeToWhereClause(a.left,b,d,e,c)+" IS NOT NULL )";case "IN":var h=[];if("expression-list"===a.right.type){if("column-reference"===a.left.type&&a.left.column.toUpperCase()===this.field.name.toUpperCase()){var g=[];h=!0;for(f of a.right.value)if("string"===f.type)if(void 0!==this.lkp[f.value])g.push(this.lkp[f.value].toString());else{h=!1;break}else{h=!1;break}if(h)return" ("+this.evaluateNodeToWhereClause(a.left,b,d,e,c)+" IN ("+g.join(",")+")) "}h=this.evaluateNodeToWhereClause(a.right,
b,d,e,c);return" ("+this.evaluateNodeToWhereClause(a.left,b,d,e,c)+" IN ("+h.join(",")+")) "}f=this.evaluateNodeToWhereClause(a.right,b,d,e,c);return Array.isArray(f)?" ("+this.evaluateNodeToWhereClause(a.left,b,d,e,c)+" IN ("+f.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(a.left,b,d,e,c)+" IN ("+f+")) ";case "NOT IN":h=[];if("expression-list"===a.right.type){if("column-reference"===a.left.type&&a.left.column.toUpperCase()===this.field.name.toUpperCase()){f=[];h=!0;for(g of a.right.value)if("string"===
g.type)if(void 0!==this.lkp[g.value])f.push(this.lkp[g.value].toString());else{h=!1;break}else{h=!1;break}if(h)return" ("+this.evaluateNodeToWhereClause(a.left,b,d,e,c)+" NOT IN ("+f.join(",")+")) "}h=this.evaluateNodeToWhereClause(a.right,b,d,e,c);return" ("+this.evaluateNodeToWhereClause(a.left,b,d,e,c)+" NOT IN ("+h.join(",")+")) "}f=this.evaluateNodeToWhereClause(a.right,b,d,e,c);return Array.isArray(f)?" ("+this.evaluateNodeToWhereClause(a.left,b,d,e,c)+" NOT IN ("+f.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(a.left,
b,d,e,c)+" NOT IN ("+f+")) ";case "BETWEEN":return e=this.evaluateNodeToWhereClause(a.right,b,d,k.BADNESS,c)," ("+this.evaluateNodeToWhereClause(a.left,b,d,k.BADNESS,c)+" BETWEEN "+e[0]+" AND "+e[1]+" ) ";case "NOTBETWEEN":return e=this.evaluateNodeToWhereClause(a.right,b,d,k.BADNESS,c)," ("+this.evaluateNodeToWhereClause(a.left,b,d,k.BADNESS,c)+" NOT BETWEEN "+e[0]+" AND "+e[1]+" ) ";case "LIKE":return""!==a.escape?" ("+this.evaluateNodeToWhereClause(a.left,b,d,k.BADNESS,c)+" LIKE "+this.evaluateNodeToWhereClause(a.right,
b,d,k.BADNESS,c)+" ESCAPE '"+a.escape+"') ":" ("+this.evaluateNodeToWhereClause(a.left,b,d,k.BADNESS,c)+" LIKE "+this.evaluateNodeToWhereClause(a.right,b,d,k.BADNESS,c)+") ";case "NOT LIKE":return""!==a.escape?" ("+this.evaluateNodeToWhereClause(a.left,b,d,k.BADNESS,c)+" NOT LIKE "+this.evaluateNodeToWhereClause(a.right,b,d,k.BADNESS,c)+" ESCAPE '"+a.escape+"') ":" ("+this.evaluateNodeToWhereClause(a.left,b,d,k.BADNESS,c)+" NOT LIKE "+this.evaluateNodeToWhereClause(a.right,b,d,k.BADNESS,c)+") ";case "\x3c\x3e":case "\x3d":if("column-reference"===
a.left.type&&"string"===a.right.type){if(a.left.column.toUpperCase()===this.field.name.toUpperCase()&&void 0!==this.lkp[a.right.value.toString()])return" ("+e+" "+a.operator+" "+this.lkp[a.right.value.toString()].toString()+") "}else if("column-reference"===a.right.type&&"string"===a.left.type&&a.right.column.toUpperCase()===this.field.name.toUpperCase())return" ("+this.lkp[a.right.value.toString()].toString()+" "+a.operator+" "+e+") ";return" ("+this.evaluateNodeToWhereClause(a.left,b,d,k.BADNESS,
c)+" "+a.operator+" "+this.evaluateNodeToWhereClause(a.right,b,d,k.BADNESS,c)+") ";case "\x3c":case "\x3e":case "\x3e\x3d":case "\x3c\x3d":case "*":case "-":case "+":case "/":case "||":return" ("+this.evaluateNodeToWhereClause(a.left,b,d,k.BADNESS,c)+" "+a.operator+" "+this.evaluateNodeToWhereClause(a.right,b,d,k.BADNESS,c)+") "}case "null":return"null";case "boolean":return!0===a.value?"1":"0";case "string":return"'"+a.value.toString().replaceAll("'","''")+"'";case "timestamp":return`timestamp '${a.value}'`;
case "date":return`date '${a.value}'`;case "time":return`time '${a.value}'`;case "number":return a.value.toString();case "current-time":return m.makeToday("date"===a.mode,b);case "column-reference":return d&&d.toLowerCase()===a.column.toLowerCase()?"("+e+")":a.column;case "data-type":return a.value;case "function":return d=this.evaluateNodeToWhereClause(a.args,b,d,k.BADNESS,c),m.translateFunctionToDatabaseSpecific(a.name,d,b)}throw new p.SqlError(p.SqlErrorCodes.UnsupportedSyntax,{node:a.type});}extractValue(a){return this.codefield instanceof
r.WhereClause?this.reverseLkp[r.WhereClause.convertValueToStorageFormat(this.codefield.calculateValueCompiled(a))]:this.reverseLkp[a.attributes[this.codefield]]}}k.BADNESS="_!!!_BAD_LKP_!!!!";class E extends t{constructor(a,b){super(a);this._sql=b}rewriteSql(a,b){return{rewritten:!0,where:m.reformulateWithoutField(a,this.field.name,m.toWhereClause(this._sql,n.FeatureServiceDatabaseType.Standardised),b.getFieldsIndex())}}extractValue(a){return r.WhereClause.convertValueToStorageFormat(this._sql.calculateValueCompiled(a),
this.field.type)}}class F extends B{static findField(a,b){for(const d of a)if(d.name.toLowerCase()===b.toString().toLowerCase())return d;return null}constructor(a){super(a);this._calcFunc=null;this.declaredClass="esri.arcade.featureset.actions.Adapted";this.adaptedFields=[];this._extraFilter=null;this._extraFilter=a.extraFilter;this._parent=a.parentfeatureset;this._maxProcessing=30;this.adaptedFields=a.adaptedFields}_initialiseFeatureSet(){null!==this._parent?(this.geometryType=this._parent.geometryType,
this.objectIdField=this._parent.objectIdField,this.globalIdField=this._parent.globalIdField,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField=this._parent.typeIdField,this.types=this._parent.types):(this.spatialReference=new D({wkid:4326}),this.globalIdField=this.objectIdField="",this.geometryType=n.layerGeometryEsriConstants.point,this.typeIdField="",this.subtypes=this.subtypeField=this.types=null);this.fields=[];for(const a of this.adaptedFields)a.postInitialization(this,
this._parent),this.fields.push(a.field)}async _getSet(a){if(null===this._wset){await this._ensureLoaded();let b=null;b=this._extraFilter?await this._getFilteredSet("",null,null,null,a):await this._parent?._getSet(a);this._checkCancelled(a);C.assertIsSome(b);this._wset=new u(b._candidates.slice(0),b._known.slice(0),b._ordered,this._clonePageDefinition(b.pagesDefinition))}return this._wset}_isInFeatureSet(a){return this._parent._isInFeatureSet(a)}async _getFeatures(a,b,d,e){var c=[];-1!==b&&void 0===
this._featureCache[b]&&c.push(b);const f=this._maxQueryRate();if(!0===this._checkIfNeedToExpandKnownPage(a,f))return await this._expandPagedSet(a,f,0,0,e),this._getFeatures(a,b,d,e);let h=0;for(let g=a._lastFetchedIndex;g<a._known.length&&!(h++,h<=d&&(a._lastFetchedIndex+=1),void 0===this._featureCache[a._known[g]]&&(a._known[g]!==b&&c.push(a._known[g]),c.length>=f));g++);if(0===c.length)return"success";a=new u([],c,a._ordered,null);b=Math.min(c.length,d);await this._parent?._getFeatures(a,-1,b,e);
this._checkCancelled(e);a=[];for(e=0;e<b;e++)d=this._parent?._featureFromCache(c[e]),void 0!==d&&a.push({geometry:d.geometry,attributes:d.attributes,id:c[e]});for(const g of a){c=[];for(const l of this.adaptedFields)c[l.field.name]=l.extractValue(g);this._featureCache[g.id]=new z({attributes:c,geometry:A.cloneGeometry(g.geometry)})}return"success"}async _fetchAndRefineFeatures(){throw new p.FeatureSetError(p.FeatureSetErrorCodes.NeverReach);}async _getFilteredSet(a,b,d,e,c){let f=!1;var h=this._reformulateWithoutAdaptions(d);
f=h.cannot;d=h.where;h=!1;if(null!==e){h=!0;const g=[];for(const l of this.adaptedFields)if(!(l instanceof v)&&!0===e.scanForField(l.field.name))if(l instanceof x)g.push({field:l.field.name,newfield:l.originalField.name});else{e=null;h=!1;break}e&&0<g.length&&(e=e.replaceFields(g))}null!==d?null!==this._extraFilter&&(d=m.combine(this._extraFilter,d)):d=this._extraFilter;await this._ensureLoaded();a=await this._parent._getFilteredSet(a,b,d,e,c);this._checkCancelled(c);return!0===f?new u(a._candidates.slice(0).concat(a._known.slice(0)),
[],!0===h?a._ordered:!1,this._clonePageDefinition(a.pagesDefinition)):new u(a._candidates.slice(0),a._known.slice(0),!0===h?a._ordered:!1,this._clonePageDefinition(a.pagesDefinition))}_reformulateWithoutAdaptions(a){const b={cannot:!1,where:a};if(null!==a)for(const d of this.adaptedFields)if(!0===m.scanForField(a,d.field.name)){const e=d.rewriteSql(a,this);if(!0===e.rewritten)b.where=e.where;else{b.cannot=!0;b.where=null;break}}return b}async _stat(a,b,d,e,c,f,h){var g=!1;let l=this._reformulateWithoutAdaptions(b);
g=l.cannot;b=l.where;l=this._reformulateWithoutAdaptions(c);g=g||l.cannot;c=l.where;null!==c?null!==this._extraFilter&&(c=m.combine(this._extraFilter,c)):c=this._extraFilter;if(!0===g)return null===c&&""===d&&null===e?this._manualStat(a,b,f,h):{calculated:!1};g=await this._parent._stat(a,b,d,e,c,f,h);return!1===g.calculated?null===c&&""===d&&null===e?this._manualStat(a,b,f,h):{calculated:!1}:g}async _canDoAggregates(a,b,d,e,c){if(null===this._parent)return!1;for(var f=0;f<a.length;f++)for(var h of this.adaptedFields)if(a[f].toLowerCase()===
h.field.name.toLowerCase()&&!(h instanceof v))return!1;f=[];for(h=0;h<b.length;h++){var g=b[h];if(null!==g.workingexpr){const l=this._reformulateWithoutAdaptions(g.workingexpr);if(l.cannot)return!1;g=g.clone();g.workingexpr=l.where;f.push(g)}else f.push(g)}b=this._reformulateWithoutAdaptions(c);if(b.cannot)return!1;c=b.where;null!==c?null!==this._extraFilter&&(c=m.combine(this._extraFilter,c)):c=this._extraFilter;return this._parent._canDoAggregates(a,f,d,e,c)}async _getAggregatePagesDataSourceDefinition(a,
b,d,e,c,f,h){if(null===this._parent)throw new p.FeatureSetError(p.FeatureSetErrorCodes.NeverReach);const g=[];for(let w=0;w<b.length;w++){var l=b[w];if(null!==l.workingexpr){const y=this._reformulateWithoutAdaptions(l.workingexpr);if(y.cannot)throw new p.FeatureSetError(p.FeatureSetErrorCodes.NeverReach);l=l.clone();l.workingexpr=y.where;g.push(l)}else g.push(l)}b=this._reformulateWithoutAdaptions(c);if(b.cannot)throw new p.FeatureSetError(p.FeatureSetErrorCodes.NeverReach);c=b.where;null!==c?null!==
this._extraFilter&&(c=m.combine(this._extraFilter,c)):c=this._extraFilter;return this._parent._getAggregatePagesDataSourceDefinition(a,g,d,e,c,f,h)}}q.AdaptedFeatureSet=F;q.AdaptedField=t;q.FieldRename=x;q.OriginalField=v;q.SqlExpressionAdapted=E;q.StringToCodeAdapted=k;Object.defineProperty(q,Symbol.toStringTag,{value:"Module"})});