Skip to content

Commit

Permalink
fix(arcgis): url remplacement may cause errors if mapserver is not en…
Browse files Browse the repository at this point in the history
…abled (#1072)

* fix(arcgis): url remplacement may cause errors if mapserver is not enabled.

* fix(arcgisrest): arcgis service was calling non existing url

Co-authored-by: Pierre-Étienne Lord <[email protected]>
  • Loading branch information
pelord and Pierre-Étienne Lord authored Oct 24, 2022
1 parent 12030ca commit 0474418
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions packages/geo/src/lib/datasource/shared/capabilities.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,34 +110,30 @@ export class CapabilitiesService {
);
}

@Cacheable({
maxCacheCount: 20
})
getArcgisOptions(
baseOptions: ArcGISRestDataSourceOptions
): Observable<ArcGISRestDataSourceOptions> {
const baseUrl = baseOptions.url + '/' + baseOptions.layer + '?f=json';
const modifiedUrl = baseOptions.url.replace('FeatureServer', 'MapServer');
const legendUrl = modifiedUrl + '/legend?f=json';
const serviceCapabilities = this.getCapabilities('arcgisrest', baseOptions.url);
const arcgisOptions = this.http.get(baseUrl);
const legend = this.http.get(legendUrl).pipe(
map((res: any) => res),
catchError((err) => {
console.log('No legend associated with this Feature Service');
return of(err);
})
);
return forkJoin([arcgisOptions, legend, serviceCapabilities]).pipe(
return forkJoin([arcgisOptions, serviceCapabilities]).pipe(
map((res: any) => {
return this.parseArcgisOptions(baseOptions, res[0], res[1], res[2]);
return this.parseArcgisOptions(baseOptions, res[0], res[1]);
})
);
}

@Cacheable({
maxCacheCount: 20
})
getImageArcgisOptions(
baseOptions: ArcGISRestImageDataSourceOptions | TileArcGISRestDataSourceOptions
): Observable<ArcGISRestImageDataSourceOptions | TileArcGISRestDataSourceOptions> {
const baseUrl = baseOptions.url + '/' + baseOptions.layer + '?f=json';
const modifiedUrl = baseOptions.url.replace('FeatureServer', 'MapServer');
const legendUrl = modifiedUrl + '/legend?f=json';
const legendUrl = baseOptions.url + '/legend?f=json';
const serviceCapabilities = this.getCapabilities('imagearcgisrest', baseOptions.url);
const arcgisOptions = this.http.get(baseUrl);
const legend = this.http.get(legendUrl).pipe(
Expand All @@ -154,6 +150,9 @@ export class CapabilitiesService {
);
}

@Cacheable({
maxCacheCount: 20
})
getTileArcgisOptions(
baseOptions: TileArcGISRestDataSourceOptions
): Observable<ArcGISRestImageDataSourceOptions | TileArcGISRestDataSourceOptions> {
Expand Down Expand Up @@ -370,15 +369,12 @@ export class CapabilitiesService {
private parseArcgisOptions(
baseOptions: ArcGISRestDataSourceOptions,
arcgisOptions: any,
legend: any,
serviceCapabilities: any,
): ArcGISRestDataSourceOptions {
const title = arcgisOptions.name;
let legendInfo: any;

if (legend.layers) {
legendInfo = legend.layers.find(x => x.layerName === title);
} else if (arcgisOptions.drawingInfo?.renderer) {
if (arcgisOptions.drawingInfo?.renderer) {
legendInfo = arcgisOptions.drawingInfo.renderer;
} else {
legendInfo = undefined;
Expand Down

0 comments on commit 0474418

Please sign in to comment.