outSpatialReference of esri/rest/support/Query

261
0
11-14-2021 11:13 AM
GuillaumeArnaud
Occasional Contributor

Hi,

In ArcGIS Experience, I try to develop an app with Query. My data has WKID = 2154 and I need to have his geometry with 4326 WKID.

I try many and many things : 

getApiModule = () => {
//Va cherche l'API Js pour dessiner
return new Promise(resolve => {loadArcGISJSAPIModules(['esri/Graphic''esri/rest/support/Query''esri/geometry/Polygon''esri/geometry/SpatialReference']).then(modules => {[
        this.graphicApithis.queryApithis.polygonApithis.spatialReferenceApi] = modules;
resolve('ok');
});});}
 
recupRequete = () => {
//Si besoin de cherche l'API de requête
if (!this.queryApi) {
this.getApiModule().then(() => { this.recupRequete() })
    } else {
//Construit la requête
const q = new this.queryApi({
where: '1=1',
outFields: ['*'],
returnGeometry: true,
outSpatialReference: { 'wkid': 4326 }
      });
console.log(q);
//Stocke la requête dans le state
this.query = q.toJSON();
    }
}
I also try with q.outSpatialReference after new. and i try in place of  { 'wkid': 4326 }
this.spatialReferenceApi.WGS84 , 4326 . 
 
The URL sent to ArcGIS server didn't have outSR parameter like I enter it directly in ArcGIS Server.
 

In Experience Builder, it seems that it is the dataSourceComponent which bring the request :

In render part :

<DataSourceComponent
useDataSource={this.props.useDataSources[0]}
widgetId={this.props.id}
query={this.query}
queryCount={true}
onDataSourceCreated={this.onDataSourceCreated}
>
    {this.recupDonnees}
</DataSourceComponent>
the functions :
onDataSourceCreated = (dsDataSource=> {
//Récupère la datasource lors de sa création
this.queryDs = ds;
  }

recupDonnees = (dsDataSourceinfoIMDataSourceInfo=> {
//Partie temporaire du stockage des options de la liste déroulante
let tmp = [];
//Si la datasource est chargée
if (info.status === DataSourceStatus.Loaded) {
//Parcours les résultats de la requête
this.queryDs.getRecords().map((rany=> {
//Construit le label e foncton des champs choisis
let label = '';
if (this.props.useDataSources[0].fields?.length == 0 || !this.props.useDataSources[0].fields) {
label += r.getData()['objectid'];
        } else {
for (let j = 0j < this.props.useDataSources[0].fields.lengthj++) {
if (j != 0) {
label += '-';
            }
label += r.getData()[this.props.useDataSources[0].fields[0]];
          }
        }
//Ajoute la donnée dans le contenu de la liste déroulante
tmp.push({ label: labelvalue: r.getData()['objectid'] + labelinfo: r });
      })
    }
//définie par défaut les coordonnées du premier enregistrement
this.destinationChange(tmp[0]);
//Remplace le contenu de la liste déroulante
this.setState({ destinations: tmp });
return null;
  }
 To get the same result with API javascript (and the projection works), You're right, I need to change recup result by : 
  recupDonnees = (dsanyinfoIMDataSourceInfo=> {
 
    if (info.status === DataSourceStatus.Loaded) {
if (ds.dataSourceJson?.query?.where?.sql) {
//get the filter apply on ds in ExB
this.query2.where += ' AND ' + ds.dataSourceJson.query.where.sql
        }
//apply the query 
this.queryTaskApi.executeQueryJSON(ds.urlthis.query2).then(function (results) {
console.log("query results: "results);
//STATE_ABBR should be "ID"
console.log("STATE_ABBR: "results.features);
        });
}
}
 Is there a mean to do this directly on the DataSourceComponent of ExB ?
 
My ArcGIS Server is in 10.6.1
 
Thanks.
 
Guillaume ARNAUD
0 Kudos
0 Replies