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

Remove Bounding Box From Vertex #1866

Open
wants to merge 5 commits into
base: test
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions src/app/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
7 changes: 7 additions & 0 deletions src/app/models/wkt-repair-response.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export interface WKTRepairResponse {
wkt: {
unwrapped: string;
wrapped: string;
}
repairs: { report: string, type: string }[];
}
13 changes: 12 additions & 1 deletion src/app/services/map/map.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand Down
15 changes: 9 additions & 6 deletions src/app/services/polygon-validation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { WktService } from './wkt.service';

import * as models from '@models';
import { NotificationService } from './notification.service';

@Injectable({
providedIn: 'root'
})
Expand All @@ -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);
Expand Down Expand Up @@ -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);

Expand All @@ -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(
Expand Down
48 changes: 5 additions & 43 deletions src/app/services/search-params.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
})
Expand All @@ -26,7 +24,6 @@ export class SearchParamsService {
private store$: Store<AppState>,
private mapService: MapService,
private rangeService: RangeService,
private drawService: DrawService
) { }


Expand Down Expand Up @@ -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(
Expand All @@ -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([
Expand Down Expand Up @@ -288,7 +250,7 @@ export class SearchParamsService {
);

public getOnDemandSearchParams = combineLatest([
this.store$.select(hyp3Store.getOnDemandUserId)
this.store$.select(hyp3Store.getOnDemandUserId)
]).pipe(
map(([userID]) => {
return {
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/url-state.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down