Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015-present Open Networking Foundation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | import { Injectable } from '@angular/core'; |
| 17 | import { FnService } from '../util/fn.service'; |
| 18 | import { LogService } from '../../log.service'; |
| 19 | |
| 20 | /** |
| 21 | * ONOS GUI -- SVG -- GeoData Service |
| 22 | * |
| 23 | * The GeoData Service facilitates the fetching and caching of TopoJSON data |
| 24 | * from the server, as well as providing a way of creating a path generator |
| 25 | * for that data, to be used to render the map in an SVG layer. |
| 26 | * |
| 27 | * A TopoData object can be fetched by ID. IDs that start with an asterisk |
| 28 | * identify maps bundled with the GUI. IDs that do not start with an |
| 29 | * asterisk are assumed to be URLs to externally provided data. |
| 30 | * |
| 31 | * var topodata = GeoDataService.fetchTopoData('*continental-us'); |
| 32 | * |
| 33 | * The path generator can then be created for that data-set: |
| 34 | * |
| 35 | * var gen = GeoDataService.createPathGenerator(topodata, opts); |
| 36 | * |
| 37 | * opts is an optional argument that allows the override of default settings: |
| 38 | * { |
| 39 | * objectTag: 'states', |
| 40 | * projection: d3.geo.mercator(), |
| 41 | * logicalSize: 1000, |
| 42 | * mapFillScale: .95 |
| 43 | * }; |
| 44 | * |
| 45 | * The returned object (gen) comprises transformed data (TopoJSON -> GeoJSON), |
| 46 | * the D3 path generator function, and the settings used ... |
| 47 | * |
| 48 | * { |
| 49 | * geodata: { ... }, |
| 50 | * pathgen: function (...) { ... }, |
| 51 | * settings: { ... } |
| 52 | * } |
| 53 | */ |
| 54 | @Injectable() |
| 55 | export class GeoDataService { |
| 56 | |
| 57 | constructor( |
| 58 | private fn: FnService, |
| 59 | // private http: HttpService, |
| 60 | private log: LogService |
| 61 | ) { |
| 62 | this.log.debug('GeoDataService constructed'); |
| 63 | } |
| 64 | |
| 65 | } |