Commit ab6bcc2c authored by Justine FERRON's avatar Justine FERRON
Browse files

majs

parent 3e1637b5
......@@ -16,6 +16,12 @@
"build-locale:en": "ng build --prod --i18n-locale en --i18n-format xlf --i18n-file src/locale/messages.en.xlf --output-path=dist/prodige_visualiseur_carto/en --baseHref /en/",
"build-locale": "npm run build-locale:fr"
},
"browser": {
"fs": false,
"http": false,
"https": false,
"txml/txml": false
},
"xliffmergeOptions": {
"srcDir": "src/locale",
"genDir": "src/locale",
......
......@@ -19,7 +19,7 @@ export class ActionButtonsOverrideComponent implements OnInit, OnDestroy {
@Input() saveGlobal = false;
public buttonModal = '';
@ContentChild('modal') modal: Component;
@ContentChild('modal', null) modal: Component;
dropdown = false;
connexionUrl: string;
paramsModal: NgbModalOptions;
......
......@@ -25,33 +25,33 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
oldScreenWidth: number;
isNavCollapsed = false;
context: Promise<FeatureCollection> | null = null;
contextSubscription: Subscription;
contextSubscription: Subscription = new Subscription;
title = 'bdl-alkante-visualiseur-core';
infoLink = '#';
helpingContent: string;
resume: string;
favoriteZones: Array<FeatureCollection['GeobookmarkConfig']> = [];
sessionStorageSubscription: Subscription;
localStorageSubscription: Subscription;
sessionStorageSubscription: Subscription = new Subscription;
localStorageSubscription: Subscription = new Subscription;
FAVORITE_STORAGE_KEY = 'favoriteZones';
HELP_STORAGE_KEY = 'isHelpPillVisible';
isHelpPillVisible;
drawLayerFeatureSubscription: Subscription;
drawLayerFeatureSubscription: Subscription = new Subscription;
drawLayerFeature = true;
userConnectionSubscription: Subscription;
userConnectionSubscription: Subscription = new Subscription;
isConnected = false;
rootLayerGroupSubscription: Subscription;
rootLayerGroupSubscription: Subscription = new Subscription;
rootLayerGroup: LayerGroup;
isMpaSheetAvailable = false;
downloadableRootLayerGroup: LayerGroup;
bufferGeneralNameIndexSubscription: Subscription;
bufferGeneralNameIndexSubscription: Subscription = new Subscription;
mapId = 'visualiseur';
mapToolSubscription: Subscription;
mapToolSubscription: Subscription = new Subscription;
wmsLayers: Array<ImageLayer> = [];
tools: FeatureCollection['properties']['extension']['Tools'];
......@@ -60,14 +60,14 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
selectedTool: string;
resultSearching = false;
resultSearchingSubscription: Subscription;
resultSearchingSubscription: Subscription = new Subscription;
resultAvailable = false;
resultAvailableSubscription: Subscription;
resultAvailableSubscription: Subscription = new Subscription;
toastResponse: string = null;
@ViewChild('copyToast') copyToast: ElementRef;
@ViewChild(InterrogatingTooltipButtonComponent) tooltipButton: InterrogatingTooltipButtonComponent;
@ViewChild(ExtractorButtonComponent) extractorButton: ExtractorButtonComponent;
@ViewChild('copyToast', null) copyToast: ElementRef;
@ViewChild(InterrogatingTooltipButtonComponent, null) tooltipButton: InterrogatingTooltipButtonComponent;
@ViewChild(ExtractorButtonComponent, null) extractorButton: ExtractorButtonComponent;
constructor(
public mapService: MapService,
......@@ -92,26 +92,26 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
this.mapService.mapZoom = 25;
this.mapService.mapCenter = [48.117266, -1.6777926];
this.drawLayerFeatureSubscription = this.drawLayerService.getHasFeature().subscribe(bool => {
this.drawLayerFeatureSubscription.add(this.drawLayerService.getHasFeature().subscribe(bool => {
setTimeout(() => {
this.drawLayerFeature = !bool;
}, 0);
});
}));
this.localStorageSubscription = this.localStorage.observe(this.HELP_STORAGE_KEY).subscribe(visible => {
this.isHelpPillVisible = visible;
});
this.bufferGeneralNameIndexSubscription = this.drawLayerService.getBufferGeneralNameIndex().subscribe(index => {
this.rootLayerGroupSubscription = this.coreService.getRootLayerGroup().subscribe(layerGroup => {
this.bufferGeneralNameIndexSubscription.add(this.drawLayerService.getBufferGeneralNameIndex().subscribe(index => {
this.rootLayerGroupSubscription.add(this.coreService.getRootLayerGroup().subscribe(layerGroup => {
this.rootLayerGroup = layerGroup;
this.isMpaSheetAvailable = this.searchForMpaSheet(this.rootLayerGroup) ? true : false;
this.downloadableRootLayerGroup = this.coreService.getDownloadableRootLayerGroup(layerGroup.getLayers());
this.drawLayerService.checkIfIndexExists(index, layerGroup);
});
});
}));
}));
this.resultAvailableSubscription = this.interrogatingService.getResultOfInterrogation().subscribe(
this.resultAvailableSubscription.add(this.interrogatingService.getResultOfInterrogation().subscribe(
( result ) => {
if ( result && result.totalResults > 0 ) {
this.resultAvailable = true;
......@@ -119,9 +119,9 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
this.resultAvailable = false;
}
}
);
));
this.resultSearchingSubscription = this.interrogatingService.getResultSearching().subscribe(
this.resultSearchingSubscription.add(this.interrogatingService.getResultSearching().subscribe(
( result ) => {
this.resultSearching = result;
if (!this.resultSearching) {
......@@ -136,13 +136,13 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
}, 500);
}
}
);
));
this.mapToolSubscription = this.coreService.getMapTool().subscribe(
this.mapToolSubscription.add(this.coreService.getMapTool().subscribe(
tool => {
this.selectedTool = tool;
}, error => console.error(error)
);
));
const subscription = this.favoriteZonesManage.getSessionFavoriteZones().subscribe(sessionFZ => {
if (sessionFZ) {
......@@ -150,7 +150,7 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
}
});
this.contextSubscription = this.coreService.getContext().subscribe(
this.contextSubscription.add(this.coreService.getContext().subscribe(
context => {
this.context = Promise.resolve(context);
......@@ -171,7 +171,7 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
this.layout = context.properties.extension.Layout;
}, error => console.error(error)
);
));
this.setDefaultAnnotationStyle();
......@@ -365,18 +365,18 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
icon: new Icon ({
src: 'data/target.png'
}),
color: 'rgba(1, 149, 254, 0.85)',
color: 'rgba(255, 0, 105, 0.87)',
offset: 0,
scale: 0,
fill: new Fill ({
color: 'rgba(0, 0, 0, 0.35)'
color: 'rgba(255, 0, 105, 0.87)'
}),
size: 7,
spacing: 10,
angle: 0
}),
stroke: new Stroke({
color: 'rgba(1, 149, 254, 0.85)',
color: 'rgba(255, 0, 105, 0.87)',
width: 3
})
});
......@@ -384,8 +384,8 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
this.drawLayerService.setPolygonStyleOptions({
settedStyle: {
size: 7,
color: 'rgba(1, 149, 254, 0.85)',
background: 'rgba(0, 0, 0, 0.35)',
color: 'rgba(255, 0, 105, 0.87)',
background: 'rgba(255, 0, 105, 0.87)',
pattern: defaultPattern,
text: null
}
......
......@@ -10,7 +10,7 @@ import { VisualiseurCoreService } from '@alkante/visualiseur-core';
})
export class ExtractorModalComponent implements OnInit, OnDestroy {
extractingOptionSubscription: Subscription;
extractingOptionSubscription: Subscription = new Subscription;
extractingOption: string;
type = 'rect';
@Input() screenMode: 'desktop' | 'mobile' = 'desktop';
......@@ -21,9 +21,9 @@ export class ExtractorModalComponent implements OnInit, OnDestroy {
ngOnInit() {
this.coreService.setExtractingOption(this.type);
this.extractingOptionSubscription = this.coreService.getExtractingOption().subscribe(option => {
this.extractingOptionSubscription.add(this.coreService.getExtractingOption().subscribe(option => {
this.extractingOption = option;
}, error => console.error(error));
}, error => console.error(error)));
}
ngOnDestroy(): void {
......
......@@ -22,9 +22,9 @@ export class ExtractorToolsComponent implements OnInit, OnDestroy {
@Input() mapId: string;
map: Map;
mapToolSubscription: Subscription;
extractingOptionSubscription: Subscription;
drawLayerSubscription: Subscription;
mapToolSubscription: Subscription = new Subscription;
extractingOptionSubscription: Subscription = new Subscription;
drawLayerSubscription: Subscription = new Subscription;
drawLayer: VectorLayer;
typeSelect: string;
draw: Draw;
......@@ -33,7 +33,7 @@ export class ExtractorToolsComponent implements OnInit, OnDestroy {
catalogueUrl: string;
format = new WKT();
@ViewChild(AlertConfirmPromptModalComponent) confirmModal: AlertConfirmPromptModalComponent;
@ViewChild(AlertConfirmPromptModalComponent, null) confirmModal: AlertConfirmPromptModalComponent;
constructor(
private drawLayerService: DrawLayerService,
......@@ -56,11 +56,11 @@ export class ExtractorToolsComponent implements OnInit, OnDestroy {
this.map = this.mapService.getMap(this.mapId || this.mapIdService.getId());
this.extractingOptionSubscription = this.coreService.getExtractingOption().subscribe(opt => {
this.extractingOptionSubscription.add(this.coreService.getExtractingOption().subscribe(opt => {
this.drawLayerService.generateNewDrawLayer(this.mapId);
this.drawLayerSubscription = this.drawLayerService.getDrawLayer().subscribe(
this.drawLayerSubscription.add(this.drawLayerService.getDrawLayer().subscribe(
( vectorLayer: VectorLayer ) => {
if ( vectorLayer ) {
this.drawLayer = vectorLayer;
......@@ -108,9 +108,9 @@ export class ExtractorToolsComponent implements OnInit, OnDestroy {
}
}
}, error => console.error(error));
}, error => console.error(error)));
}
);
));
}
ngOnDestroy() {
......
......@@ -13,6 +13,7 @@ import { WKT } from 'ol/src/format';
import LayerGroup from 'ol/src/layer/Group';
import { Style, Fill, Stroke } from 'ol/src/style';
import { getArea } from 'ol/src/sphere';
import { getCenter } from 'ol/extent';
import Map from 'ol/src/Map';
@Component({
......@@ -23,6 +24,7 @@ import Map from 'ol/src/Map';
export class ExportFoncierModalComponent implements OnInit, OnDestroy {
map: Map;
mapId: string;
exportForm = new FormGroup({
titre: new FormControl('', Validators.required),
......@@ -35,12 +37,14 @@ export class ExportFoncierModalComponent implements OnInit, OnDestroy {
format: new FormControl('A4', Validators.required),
});
rootLayerGroupSubscription: Subscription;
subscriptions: Subscription = new Subscription();
//rootLayerGroupSubscription: Subscription = new Subscription;
private rootLayerGroup: LayerGroup;
contextSubscription: Subscription;
//contextSubscription: Subscription = new Subscription;
private newContext: FeatureCollection;
private context: FeatureCollection;
editingToolSubscription: Subscription;
//editingToolSubscription: Subscription = new Subscription;
lastFeatureAdded: any = null;
format = new WKT();
......@@ -57,99 +61,106 @@ export class ExportFoncierModalComponent implements OnInit, OnDestroy {
ngOnInit() {
this.mapService.getMapReady(this.mapIdService.getId() || 'visualiseur' || 'main').subscribe(map => {
this.map = map;
});
this.contextSubscription = this.coreService.getContext().subscribe(context => {
this.subscriptions.add(this.coreService.getContext().subscribe(context => {
this.context = context;
this.newContext = JSON.parse(JSON.stringify(this.context));
this.exportForm.get('titre').setValue(context.properties.title);
});
this.rootLayerGroup = this.coreService.generateLayersAndLayerGroups(context.properties.extension.layers);;
}));
this.rootLayerGroupSubscription = this.coreService.getRootLayerGroup().subscribe(layerGroup => {
this.rootLayerGroup = layerGroup;
console.log(this.rootLayerGroup);
});
this.mapId = this.mapIdService.getId() || 'visualiseur' || 'main';
this.subscriptions.add(this.mapService.getMapReady(this.mapId).subscribe(map => {
this.map = map;
this.editingToolSubscription = this.editingToolService.getGlobalFeature().subscribe(feature => {
console.log(feature);
this.lastFeatureAdded = feature;
if (this.lastFeatureAdded) {
this.exportForm.get('identifiant').setValue(this.lastFeatureAdded.properties.gid);
this.exportForm.get('nom').setValue(this.lastFeatureAdded.properties.nom);
this.exportForm.get('prenom').setValue(this.lastFeatureAdded.properties.prenom);
this.exportForm.get('ref').setValue(this.lastFeatureAdded.properties.ref_cadast);
this.exportForm.get('commentaire').setValue(this.lastFeatureAdded.properties.commentaire);
// Ajout d'un layer avec la feature
let feature = this.format.readFeature(this.lastFeatureAdded.geometry);
const area = (
(this.map.getView().getProjection().getUnits() == 'degrees')
? getArea(feature.getGeometry(), { projection: this.map.getView().getProjection() })
: feature.getGeometry().getArea()
);
const areaInHa = (Math.round(area / 10000 * 100) / 100);
if (this.map) {
this.subscriptions.add(this.editingToolService.getGlobalFeature().subscribe(feature => {
console.log(feature);
this.lastFeatureAdded = feature;
if (this.lastFeatureAdded) {
this.exportForm.get('identifiant').setValue(this.lastFeatureAdded.properties.gid);
this.exportForm.get('nom').setValue(this.lastFeatureAdded.properties.nom);
this.exportForm.get('prenom').setValue(this.lastFeatureAdded.properties.prenom);
this.exportForm.get('ref').setValue(this.lastFeatureAdded.properties.ref_cadast);
this.exportForm.get('commentaire').setValue(this.lastFeatureAdded.properties.commentaire);
// Ajout d'un layer avec la feature
let feature = this.format.readFeature(this.lastFeatureAdded.geometry);
const area = (
(this.map.getView().getProjection().getUnits() == 'degrees')
? getArea(feature.getGeometry(), { projection: this.map.getView().getProjection() })
: feature.getGeometry().getArea()
);
const areaInHa = (Math.round(area / 10000 * 100) / 100);
this.exportForm.get('surface').setValue(areaInHa);
this.exportForm.get('surface').setValue(areaInHa);
this.drawLayerService.getPolygonStyleOptions().subscribe(style => {
feature.set('settedStyle', style);
let vectorSource = new VectorSource({
features: [feature]
});
vectorSource.set('class', 'VectorSource');
let vectorLayer = new VectorLayer({
source: vectorSource,
zIndex: Infinity,
style: new Style({
fill: new Fill({
color: 'rgba(1, 149, 254, 0.85)',
size: 7,
}),
stroke: new Stroke({
color: 'rgba(1, 149, 254, 0.85)',
width: 3
})
})
});
vectorLayer.set('name', 'Donnée Ofag éditée');
vectorLayer.set('visibleChecked', true);
vectorLayer.set('class', 'VectorLayer');
let rootLayerGroup: LayerGroup = this.rootLayerSearchRecursive(this.rootLayerGroup.getLayers());
rootLayerGroup.getLayers().insertAt(0, vectorLayer);
this.mapService.verifyLayerGroupVisibility(rootLayerGroup, (this.mapIdService.getId()));
this.newContext.properties.extension.layers.layers = this.coreService.contextLayersAndLayerGroups(rootLayerGroup.getLayers());
});
this.drawLayerService.getPolygonStyleOptions().subscribe((style: any) => {
feature.set('settedStyle', style.settedStyle);
let vectorSource = new VectorSource({
features: [feature]
});
vectorSource.set('class', 'VectorSource');
let vectorLayer = new VectorLayer({
source: vectorSource,
zIndex: Infinity,
style: new Style({
fill: new Fill({
color: 'rgba(255, 0, 105, 0.87)',
size: 7,
}),
stroke: new Stroke({
color: 'rgba(255, 0, 105, 0.87)',
width: 3
})
})
});
vectorLayer.set('name', 'Donnée Ofag éditée');
vectorLayer.set('visibleChecked', true);
vectorLayer.set('class', 'VectorLayer');
console.log(vectorLayer);
let rootLayerGroup: LayerGroup = this.rootLayerSearchRecursive(this.rootLayerGroup.getLayers());
rootLayerGroup.getLayers().insertAt(0, vectorLayer);
this.mapService.verifyLayerGroupVisibility(rootLayerGroup, (this.mapId));
this.newContext.properties.extension.layers.layers = this.coreService.contextLayersAndLayerGroups(rootLayerGroup.getLayers());
});
}
}));
}
});
}));
}
ngOnDestroy() {
if (this.editingToolSubscription) {
if (this.subscriptions) {
this.subscriptions.unsubscribe();
}
/* if (this.editingToolSubscription) {
this.editingToolSubscription.unsubscribe();
}
if (this.contextSubscription) {
this.contextSubscription.unsubscribe();
}
} */
}
setVisible(layerGroup) {
layerGroup.forEach(rootLayer => {
console.log(rootLayer);
if (rootLayer.class === 'LayerGroup') {
rootLayer = this.setVisible(rootLayer.layers);
} else {
rootLayer.options.visible = true;
}
});
if (layerGroup) {
layerGroup.forEach(rootLayer => {
console.log(rootLayer);
if (rootLayer.class === 'LayerGroup') {
rootLayer = this.setVisible(rootLayer.layers);
} else {
rootLayer.options.visible = true;
}
});
}
}
rootLayerSearchRecursive(root: Collection<BaseLayer>, layerGroup: LayerGroup = null): LayerGroup {
......@@ -204,6 +215,11 @@ export class ExportFoncierModalComponent implements OnInit, OnDestroy {
let coords = feature.getGeometry().getCoordinates();
this.newContext.properties.bbox = feature.getGeometry().getExtent();
let x = this.newContext.properties.bbox[0] + (this.newContext.properties.bbox[2] - this.newContext.properties.bbox[0])/2;
let y = this.newContext.properties.bbox[1] + (this.newContext.properties.bbox[3] - this.newContext.properties.bbox[1])/2;
console.log([x, y]);
console.log(getCenter(feature.getGeometry().getExtent()));
this.setVisible(this.newContext.properties.extension.layers.layers);
/* this.newContext.properties.extension.maxBbox = feature.getGeometry().getExtent(); */
......
......@@ -12,7 +12,7 @@
// carte_interactive_irve_en_service_des_aires_du_rrn.map
$ENV.serverUrl = 'https://carto.geoguyane.fr/';
$ENV.scaleList = [ 1, 2500, 5000, 8100, 36100, 50000, 100000, 250000, 500000, 1000000, 2000000, 4000000, 10000000 ];
$ENV.scaleList = [ 1, 2500, 5000, 10000, 18100, 36100, 50000, 100000, 250000, 500000, 1000000, 2000000, 4000000, 10000000 ];
// $ENV.serverUrl = 'https://carto.prodige.internal/';
// $ENV.serverUrl = 'https://carto-test.atlasante.fr/';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment