Skip to content

Commit

Permalink
feat(SourceTileWMTSComponent): add wmts source component and wmts gri…
Browse files Browse the repository at this point in the history
…d tile component

grid tile wmts has to be a child component of wms source to be compliant
with Openlayers architecture. As the tileGrid parameter of source WMTS
is mandatory, source intance is created after content initialization
with tile grid child component instance as value for tileGrid
  • Loading branch information
Yakoust committed Aug 11, 2017
1 parent 1510c62 commit 9e029ed
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
node_modules/*
npm-debug.log

# compiled output
/dist

# JetBrains
.idea
.project
Expand Down
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"core-js": "^2.4.1",
"rxjs": "^5.1.0",
"zone.js": "^0.8.4",
"angular2-openlayers": "^0.6.5"
"angular2-openlayers": "0.6.8"
},
"devDependencies": {
"@angular/cli": "1.0.4",
Expand Down
1 change: 1 addition & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export * from './geometry.components';
export * from './map.component';
export * from './overlay.component';
export * from './tilegrid.component';
export * from './tilegridwmts.component';
export * from './view.component';
1 change: 1 addition & 0 deletions src/components/sources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export * from './vectortile.component';
export * from './xyz.component';
export * from './tilewms.component';
export * from './geojson.component';
export * from './tilewmts.component';
59 changes: 59 additions & 0 deletions src/components/sources/tilewmts.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { Component, Host, Input, OnInit, forwardRef, AfterContentInit , ContentChild } from '@angular/core';
import {
TileLoadFunctionType,
AttributionLike,
tilegrid,
ProjectionLike,
source,
ImageTile,
TileCoord,
Tile
} from 'openlayers';
import { LayerTileComponent } from '../layers';
import { SourceComponent } from './source.component';
import { TileGridWMTSComponent } from '../tilegridwmts.component';

@Component({
selector: 'aol-source-tilewmts',
template: `<ng-content></ng-content>`,
providers: [
{ provide: SourceComponent, useExisting: forwardRef(() => SourceTileWMTSComponent) }
]
})
export class SourceTileWMTSComponent extends SourceComponent implements AfterContentInit {

instance: source.WMTS;
@Input() cacheSize?: number;
@Input() crossOrigin?: (string);
@Input() logo?: (string | olx.LogoOptions);
@Input() tileGrid: tilegrid.WMTS;
@Input() projection: ProjectionLike;
@Input() reprojectionErrorThreshold?: number;
@Input() requestEncoding?: (source.WMTSRequestEncoding | string);
@Input() layer: string;
@Input() style: string;
@Input() tileClass?: ((n: ImageTile, coords: TileCoord, state: Tile.State, s1: string, s2: string, type: TileLoadFunctionType) => any);
@Input() tilePixelRatio?: number;
@Input() version?: string;
@Input() format?: string;
@Input() matrixSet: string;
@Input() dimensions?: GlobalObject;
@Input() url?: string;
@Input() tileLoadFunction?: TileLoadFunctionType;
@Input() urls?: string[];
@Input() wrapX?: boolean;

@ContentChild(TileGridWMTSComponent) tileGridWMTS: TileGridWMTSComponent;

constructor( @Host() layer: LayerTileComponent) {
super(layer);
}

ngAfterContentInit(): void {
if (this.tileGridWMTS) {
this.tileGrid = this.tileGridWMTS.instance;
this.instance = new source.WMTS(this);
this.host.instance.setSource(this.instance);
}
}
}
23 changes: 23 additions & 0 deletions src/components/tilegridwmts.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Component, Input, OnInit } from '@angular/core';
import { tilegrid, Extent, Size, Coordinate } from 'openlayers';
import { TileGridComponent } from './tilegrid.component';

@Component({
selector: 'aol-tilegrid-wmts',
template: ''
})
export class TileGridWMTSComponent extends TileGridComponent implements OnInit {
instance: tilegrid.WMTS;

@Input() origin?: Coordinate;
@Input() origins?: Coordinate[];
@Input() resolutions: number[];
@Input() matrixIds: string[];
@Input() sizes?: Size[];
@Input() tileSizes?: ((number | Size)[]);
@Input() widths?: number[];

ngOnInit() {
this.instance = new tilegrid.WMTS(this);
}
}
3 changes: 2 additions & 1 deletion src/components/view.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Input, OnInit, OnChanges, OnDestroy, SimpleChanges } from '@angular/core';
import { View, Extent } from 'openlayers';
import { View, Extent, Coordinate } from 'openlayers';
import { MapComponent } from './map.component';

@Component({
Expand All @@ -22,6 +22,7 @@ export class ViewComponent implements OnInit, OnChanges, OnDestroy {
@Input() rotation: number;
@Input() zoom: number;
@Input() zoomFactor: number;
@Input() center: Coordinate;

constructor(private host: MapComponent) {
}
Expand Down
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import {
MapComponent, ViewComponent,
LayerTileComponent, LayerVectorComponent, LayerVectorTileComponent,
SourceBingmapsComponent, SourceOsmComponent, SourceVectorComponent, SourceVectorTileComponent, SourceXYZComponent, SourceTileWMSComponent,
SourceGeoJSONComponent, FeatureComponent,
SourceGeoJSONComponent, SourceTileWMTSComponent, FeatureComponent,
GeometryLinestringComponent, GeometryPointComponent, GeometryPolygonComponent,
CollectionCoordinatesComponent, CoordinateComponent,
StyleCircleComponent, StyleComponent, StyleFillComponent, StyleIconComponent, StyleStrokeComponent, StyleTextComponent,
ControlAttributionComponent, ControlFullScreenComponent, ControlMousePositionComponent,
ControlOverviewMapComponent, ControlRotateComponent, ControlScaleLineComponent, ControlZoomComponent, ControlZoomSliderComponent,
ControlZoomToExtentComponent, DefaultControlComponent, ControlComponent,
FormatMVTComponent,
TileGridComponent,
TileGridComponent, TileGridWMTSComponent,
DefaultInteractionComponent, DragRotateInteractionComponent, DragRotateAndZoomInteractionComponent,
DoubleClickZoomInteractionComponent, DragAndDropInteractionComponent, DragBoxInteractionComponent,
DragPanInteractionComponent, DragZoomInteractionComponent, MouseWheelZoomInteractionComponent,
Expand Down Expand Up @@ -40,6 +40,7 @@ const COMPONENTS = [
SourceXYZComponent,
SourceVectorTileComponent,
SourceTileWMSComponent,
SourceTileWMTSComponent,
SourceGeoJSONComponent,
FeatureComponent,
GeometryLinestringComponent,
Expand Down Expand Up @@ -69,6 +70,7 @@ const COMPONENTS = [

FormatMVTComponent,
TileGridComponent,
TileGridWMTSComponent,

DefaultInteractionComponent,
DoubleClickZoomInteractionComponent,
Expand Down

0 comments on commit 9e029ed

Please sign in to comment.