Compare commits

..

No commits in common. "48574dc0b0d8343b7e6d972801c82d3b0fc8e220" and "aa1ad9f8444674cb3fe6a63c9b357fe31716cddf" have entirely different histories.

3 changed files with 39 additions and 75 deletions

8
Jenkinsfile vendored
View File

@ -8,13 +8,13 @@ pipeline {
stage('npm install'){ stage('npm install'){
steps { steps {
sh '''rm -rf node_modules/ sh '''rm -rf node_modules/
npm install --legacy-peer-deps npm install
cd projects/common cd projects/common
npm install --legacy-peer-deps npm install
cd ../common-map cd ../common-map
npm install --legacy-peer-deps npm install
cd ../common-map3d cd ../common-map3d
npm install --legacy-peer-deps npm install
''' '''
} }
} }

View File

@ -164,8 +164,7 @@ export {
ITemporalItemLayer, ITemporalItemLayer,
TemporalItemLayer, TemporalItemLayer,
ifZoomToShowDirective, ifZoomToShowDirective,
ZoomToShowAlert, ZoomToShowAlert
IClickedFeature
} }
@NgModule({ @NgModule({

View File

@ -1,4 +1,4 @@
import { Component, Input, AfterViewInit, ViewChild } from '@angular/core'; import { Component, Input, OnInit,ViewChild } from '@angular/core';
import { Feature} from 'ol'; import { Feature} from 'ol';
import { Geometry,Polygon,MultiPolygon } from 'ol/geom'; import { Geometry,Polygon,MultiPolygon } from 'ol/geom';
import * as extent from 'ol/extent'; import * as extent from 'ol/extent';
@ -10,86 +10,51 @@ import * as style from 'ol/style';
templateUrl: './feature-thumbnail.component.html', templateUrl: './feature-thumbnail.component.html',
styleUrls: ['./feature-thumbnail.component.scss'] styleUrls: ['./feature-thumbnail.component.scss']
}) })
export class GeometryThumbnailComponent implements AfterViewInit { export class GeometryThumbnailComponent implements OnInit {
constructor() { } constructor() { }
@ViewChild('canvas') canvas; @ViewChild('canvas') canvas;
@ViewChild('container') container; @ViewChild('container') container;
@Input('feature') feature:Feature<Geometry>;
private geometry:Geometry = null; ngOnInit(): void {
@Input() set feature(value:Feature<Geometry>) {
if(value) {
this.geometry = value.getGeometry();
} else {
this.geometry = null;
}
this.render(this.canvas,
this.geometryStyle,
this.geometry,
this.width,
this.height);
};
private defaultStyle:style.Style = new style.Style({
stroke: new style.Stroke({ color: 'black',width:1.5 })
});
private geometryStyle:style.Style = this.defaultStyle;
@Input() set fillColor(value:string) {
if(style) {
this.geometryStyle = new style.Style({
stroke: new style.Stroke({ color: 'black',width:1.5 }),
fill: new style.Fill({color: value})
});
} else {
this.geometryStyle = this.defaultStyle
}
this.render(this.canvas,
this.geometryStyle,
this.geometry,
this.width,
this.height);
} }
private width:number = 0; render(canvas,width,height,geometry:Geometry) {
private height:number = 0; let renderContext = render.toContext(canvas.getContext( '2d'),{ size: [width, height] });
let strokeStyle = new style.Style({
stroke: new style.Stroke({ color: 'black',width:1.5 })
});
render(canvas,style:style.Style,geometry:Geometry,width:number,height:number) { let geom = geometry.clone() as Polygon,
if(canvas && canvas.nativeElement && geometry && style) { line = geom.getCoordinates()[0],
let renderContext = render.toContext(canvas.nativeElement.getContext( '2d'),{ size: [width, height] }); e = extent.boundingExtent( line );
let geom = geometry.clone(), let dxy = extent.getCenter(e),
line = geom.getCoordinates()[0], sxy = [
e = extent.boundingExtent( line ); (width - 2 ) / extent.getWidth(e),
(height - 2 ) / extent.getHeight(e)
let dxy = extent.getCenter(e), ];
sxy = [
(width - 2 ) / extent.getWidth(e), let dx = dxy[0],
(height - 2 ) / extent.getHeight(e) dy = dxy[1],
]; sx = sxy[0],
sy = sxy[1];
let dx = dxy[0],
dy = dxy[1], geom.translate( -dx, -dy );
sx = sxy[0], geom.scale( Math.min(sx, sy), -Math.min(sx, sy));
sy = sxy[1]; geom.translate( width / 2, height / 2 );
geom.translate( -dx, -dy ); renderContext.setStyle( strokeStyle );
geom.scale( Math.min(sx, sy), -Math.min(sx, sy)); renderContext.drawGeometry( geom );
geom.translate(width / 2,height / 2 );
renderContext.setStyle( style );
renderContext.drawGeometry( geom );
}
} }
ngAfterViewInit() { ngAfterViewInit() {
this.width = this.container.nativeElement.offsetWidth; this.render(this.canvas.nativeElement,
this.height = this.container.nativeElement.offsetHeight; this.container.nativeElement.offsetWidth,
this.render(this.canvas, this.container.nativeElement.offsetHeight,
this.geometryStyle, this.feature.getGeometry());
this.geometry,
this.width,
this.height);
} }
} }