Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapserver errors #867

Merged
merged 5 commits into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ export class CapabilitiesService {
const timeFilter = this.getTimeFilter(layer);
const timeFilterable = timeFilter && Object.keys(timeFilter).length > 0;
const legendOptions = layer.Style ? this.getStyle(layer.Style) : undefined;

const extent = layer.EX_GeographicBoundingBox ?
olproj.transformExtent(layer.EX_GeographicBoundingBox, 'EPSG:4326', 'EPSG:3857') :
undefined;
Expand Down
5 changes: 4 additions & 1 deletion packages/geo/src/lib/layer/shared/layer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
} from './layers';

import { StyleService } from './style.service';
import { LanguageService, MessageService } from '@igo2/core';

@Injectable({
providedIn: 'root'
Expand All @@ -48,6 +49,8 @@ export class LayerService {
private http: HttpClient,
private styleService: StyleService,
private dataSourceService: DataSourceService,
private messageService: MessageService,
private languageService: LanguageService,
@Optional() private authInterceptor: AuthInterceptor
) {}

Expand Down Expand Up @@ -117,7 +120,7 @@ export class LayerService {
}

private createImageLayer(layerOptions: ImageLayerOptions): ImageLayer {
return new ImageLayer(layerOptions, this.authInterceptor);
return new ImageLayer(layerOptions, this.messageService, this.languageService, this.authInterceptor);
}

private createTileLayer(layerOptions: TileLayerOptions): TileLayer {
Expand Down
16 changes: 14 additions & 2 deletions packages/geo/src/lib/layer/shared/layers/image-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { WMSDataSource } from '../../../datasource/shared/datasources/wms-dataso
import { Layer } from './layer';
import { ImageLayerOptions } from './image-layer.interface';
import { ImageArcGISRestDataSource } from '../../../datasource/shared/datasources/imagearcgisrest-datasource';
import { LanguageService, MessageService } from '@igo2/core';

export class ImageLayer extends Layer {
public dataSource: WMSDataSource | ImageArcGISRestDataSource;
Expand All @@ -21,6 +22,8 @@ export class ImageLayer extends Layer {

constructor(
options: ImageLayerOptions,
private messageService: MessageService,
private languageService: LanguageService,
public authInterceptor?: AuthInterceptor
) {
super(options, authInterceptor);
Expand All @@ -36,7 +39,7 @@ export class ImageLayer extends Layer {
const image = new olLayerImage(olOptions);
if (this.authInterceptor) {
(image.getSource() as any).setImageLoadFunction((tile, src) => {
this.customLoader(tile, src, this.authInterceptor);
this.customLoader(tile, src, this.authInterceptor, this.messageService, this.languageService);
});
}

Expand All @@ -52,7 +55,7 @@ export class ImageLayer extends Layer {
super.setMap(map);
}

private customLoader(tile, src, interceptor) {
private customLoader(tile, src, interceptor, messageService, languageService) {
const xhr = new XMLHttpRequest();
xhr.open('GET', src);

Expand All @@ -67,6 +70,15 @@ export class ImageLayer extends Layer {

xhr.onload = function() {
const arrayBufferView = new Uint8Array((this as any).response);
const responseString = new TextDecoder().decode(arrayBufferView);
if (responseString.includes('ServiceExceptionReport')) {
messageService.error(languageService.translate.instant(
'igo.geo.dataSource.optionsApiUnavailable'
),
languageService.translate.instant(
'igo.geo.dataSource.unavailableTitle'
));
}
const blob = new Blob([arrayBufferView], { type: 'image/png' });
const urlCreator = window.URL;
const imageUrl = urlCreator.createObjectURL(blob);
Expand Down