forked from camptocamp/ogc-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathows.ts
More file actions
52 lines (51 loc) · 1.8 KB
/
ows.ts
File metadata and controls
52 lines (51 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import type { XmlDocument } from '@rgrove/parse-xml';
import type { Provider } from './models.js';
import {
findChildElement,
getElementAttribute,
getElementText,
getRootElement,
} from './xml-utils.js';
/**
* Read standard OWS provider information from capabilities
* @param capabilitiesDoc
*/
export function readProviderFromCapabilities(
capabilitiesDoc: XmlDocument
): Provider {
const serviceProvider = findChildElement(
getRootElement(capabilitiesDoc),
'ServiceProvider'
);
const serviceContact = findChildElement(serviceProvider, 'ServiceContact');
const contactInfo = findChildElement(serviceContact, 'ContactInfo');
const phone = findChildElement(contactInfo, 'Phone');
const address = findChildElement(contactInfo, 'Address');
return {
name: getElementText(findChildElement(serviceProvider, 'ProviderName')),
site: getElementAttribute(
findChildElement(serviceProvider, 'ProviderSite'),
'xlink:href'
),
contact: {
name: getElementText(findChildElement(serviceContact, 'IndividualName')),
position: getElementText(
findChildElement(serviceContact, 'PositionName')
),
phone: getElementText(findChildElement(phone, 'Voice')),
fax: getElementText(findChildElement(phone, 'Facsimile')),
address: {
deliveryPoint: getElementText(
findChildElement(address, 'DeliveryPoint')
),
city: getElementText(findChildElement(address, 'City')),
administrativeArea: getElementText(
findChildElement(address, 'AdministrativeArea')
),
postalCode: getElementText(findChildElement(address, 'PostalCode')),
country: getElementText(findChildElement(address, 'Country')),
},
email: getElementText(findChildElement(address, 'ElectronicMailAddress')),
},
};
}