diff --git a/src/app/models/index.ts b/src/app/models/index.ts index 5dbf6da79..c0bedc627 100644 --- a/src/app/models/index.ts +++ b/src/app/models/index.ts @@ -28,3 +28,4 @@ export * from './download.model'; export * from './event-product-sort.model'; export * from './asf-website.model'; export * from './mapbox.model'; +export * from './wkt-repair-response.model'; \ No newline at end of file diff --git a/src/app/models/wkt-repair-response.model.ts b/src/app/models/wkt-repair-response.model.ts new file mode 100644 index 000000000..777ca9370 --- /dev/null +++ b/src/app/models/wkt-repair-response.model.ts @@ -0,0 +1,7 @@ +export interface WKTRepairResponse { + wkt: { + unwrapped: string; + wrapped: string; + } + repairs: { report: string, type: string }[]; +} \ No newline at end of file diff --git a/src/app/services/map/map.service.ts b/src/app/services/map/map.service.ts index dd3fe3284..f5f588949 100644 --- a/src/app/services/map/map.service.ts +++ b/src/app/services/map/map.service.ts @@ -54,7 +54,7 @@ export class MapService { tap(isDrawing => this.map.getViewport().style.cursor = isDrawing ? 'crosshair' : 'default') ); - private mapView: views.MapView; + public mapView: views.MapView = views.equatorial(); private map: Map; private scaleLine: ScaleLine; @@ -340,6 +340,17 @@ export class MapService { this.setMap(view, overlay); } + public getMapView(): models.MapViewType { + switch(this.mapView) { + case views.antarctic(): + return models.MapViewType.ANTARCTIC; + case views.arctic(): + return models.MapViewType.ARCTIC; + default: + return models.MapViewType.EQUATORIAL; + } + } + public clearSelectedScene(): void { this.selectedSource.clear(); this.selectClick.getFeatures().clear(); diff --git a/src/app/services/polygon-validation.service.ts b/src/app/services/polygon-validation.service.ts index e4dcd677e..7bc6896c0 100644 --- a/src/app/services/polygon-validation.service.ts +++ b/src/app/services/polygon-validation.service.ts @@ -9,7 +9,6 @@ import { WktService } from './wkt.service'; import * as models from '@models'; import { NotificationService } from './notification.service'; - @Injectable({ providedIn: 'root' }) @@ -33,9 +32,13 @@ export class PolygonValidationService { return skip; }), filter(p => !!p || this.polygons.has(p)), - switchMap(polygon => this.asfApiService.validate(polygon).pipe( - catchError(_ => of(null)) - )), + // filter(([_, polygon]) => ), + switchMap(wkt => { + return this.asfApiService.validate(wkt).pipe( + catchError(_ => of(null)) + ); + + }), filter(resp => !!resp), map(resp => { const error = this.getErrorFrom(resp); @@ -70,7 +73,7 @@ export class PolygonValidationService { ); } - private setValidPolygon(resp) { + private setValidPolygon(resp: models.WKTRepairResponse) { this.polygons.add(resp.wkt.unwrapped); this.mapService.setDrawStyle(models.DrawPolygonStyle.VALID); @@ -83,7 +86,7 @@ export class PolygonValidationService { return resp.wkt.unwrapped; } - const { report, type } = resp.repairs.pop(); + const { report, type } = resp.repairs.pop(); if (type !== models.PolygonRepairTypes.WRAP && type !== models.PolygonRepairTypes.REVERSE) { this.notificationService.info( diff --git a/src/app/services/search-params.service.ts b/src/app/services/search-params.service.ts index 2e14aa069..0edb6a203 100644 --- a/src/app/services/search-params.service.ts +++ b/src/app/services/search-params.service.ts @@ -16,8 +16,6 @@ import { MapService } from './map/map.service'; import { RangeService } from './range.service'; import * as models from '@models'; -import { DrawService } from './map/draw.service'; -import { Polygon } from 'ol/geom'; @Injectable({ providedIn: 'root' }) @@ -26,7 +24,6 @@ export class SearchParamsService { private store$: Store, private mapService: MapService, private rangeService: RangeService, - private drawService: DrawService ) { } @@ -63,7 +60,7 @@ export class SearchParamsService { withLatestFrom(this.store$.select(filterStore.getSelectedDatasetId)), map(([useCalibrationData, dataset]) => dataset === models.opera_s1.id && useCalibrationData ? - ({dataset: models.opera_s1.calibrationDatasets}) : ({})) + ({ dataset: models.opera_s1.calibrationDatasets }) : ({})) ) private groupID$ = this.store$.select(filterStore.getGroupID).pipe( @@ -75,45 +72,10 @@ export class SearchParamsService { private searchPolygon$ = combineLatest([ this.mapService.searchPolygon$.pipe(startWith(null)), this.store$.select(filterStore.getShouldOmitSearchPolygon), - this.drawService.polygon$] + ] ).pipe( - map(([polygon, shouldOmitGeoRegion, asdf]) => shouldOmitGeoRegion ? null : { polygon: polygon, thing: asdf }), - map(polygon => { - - let feature = polygon.thing; - - - const geom = feature?.getGeometry() - if (geom instanceof Polygon) { - let points = (geom as Polygon).getCoordinates() - if (points && points[0].length === 5) { - const clonedFeature = feature.clone(); - const clonedProperties = JSON.parse(JSON.stringify(feature.getProperties())); - clonedProperties.geometry = clonedFeature.getGeometry(); - clonedFeature.setProperties(clonedProperties, true); - feature = clonedFeature; - const rectangle = feature.getGeometry() as Polygon; - rectangle.transform(this.mapService.epsg(), 'EPSG:4326'); - const outerHull = rectangle.getCoordinates()[0].slice(0, 4); - let extent = [...outerHull[0], ...outerHull[2]]; - if (JSON.stringify(rectangle.getExtent()) === JSON.stringify(extent)) { - extent = extent.map(value => { - if (value > 180) { - value = value % 360 - 360; - } - if (value < -180) { - value = value % 360 + 360; - } - return value; - }); - return { bbox: extent.join(',') }; - } - } - } - - - return { intersectsWith: polygon.polygon }; - }) + map(([polygon, shouldOmitGeoRegion]) => shouldOmitGeoRegion ? null : { wkt: polygon }), + map(aoi => ({intersectsWith: aoi.wkt })) ); private selectedDataset$ = combineLatest([ @@ -288,7 +250,7 @@ export class SearchParamsService { ); public getOnDemandSearchParams = combineLatest([ - this.store$.select(hyp3Store.getOnDemandUserId) + this.store$.select(hyp3Store.getOnDemandUserId) ]).pipe( map(([userID]) => { return { diff --git a/src/app/services/url-state.service.ts b/src/app/services/url-state.service.ts index 3cdffcf0e..ef1ea132a 100644 --- a/src/app/services/url-state.service.ts +++ b/src/app/services/url-state.service.ts @@ -54,7 +54,7 @@ export class UrlStateService { private rangeService: RangeService, private router: Router, private prop: PropertyService, - private themeService: ThemingService, + private themeService: ThemingService ) { const params = [ ...this.datasetParam(),