-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from dfpc-coe/basemaps
Basemap XML Parsing
- Loading branch information
Showing
27 changed files
with
690 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import CoT from './lib/cot.js'; | ||
export * as Feature from './lib/feature.js' | ||
export * as Types from './lib/types.js' | ||
export * as CoTTypes from './lib/cot-types.js' | ||
export * as Feature from './lib/types/feature.js' | ||
export * as Types from './lib/types/types.js' | ||
export * as CoTTypes from './lib/types/cot-types.js' | ||
export * from './lib/chat.js' | ||
export * from './lib/fileshare.js' | ||
export * from './lib/force-delete.js' | ||
export * from './lib/data-package.js' | ||
export * from './lib/basemap.js' | ||
|
||
export default CoT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import type { Static } from '@sinclair/typebox' | ||
import Err from '@openaddresses/batch-error'; | ||
import BasemapType from './types/basemap.js'; | ||
import xmljs from 'xml-js'; | ||
import AJV from 'ajv'; | ||
|
||
const checkBasemap = (new AJV({ | ||
allErrors: true, | ||
coerceTypes: true, | ||
allowUnionTypes: true | ||
})) | ||
.compile(BasemapType); | ||
|
||
/** | ||
* Helper class for creating and parsing Basemap XML documents | ||
*/ | ||
export class Basemap { | ||
basemap: Static<typeof BasemapType>; | ||
|
||
constructor(basemap: Static<typeof BasemapType>) { | ||
this.basemap = basemap; | ||
} | ||
|
||
/** | ||
* Return a Basemap from a string XML representation | ||
*/ | ||
static async parse(input: string): Promise<Basemap> { | ||
const xml = xmljs.xml2js(input, { compact: true }) | ||
|
||
checkBasemap(xml); | ||
if (checkBasemap.errors) throw new Err(400, null, `${checkBasemap.errors[0].message} (${checkBasemap.errors[0].instancePath})`); | ||
const basemap = xml as Static<typeof BasemapType>; | ||
|
||
return new Basemap(basemap); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Type } from '@sinclair/typebox'; | ||
|
||
export const BasemapMapSource = Type.Object({ | ||
name: Type.Object({ | ||
_text: Type.String() | ||
}), | ||
minZoom: Type.Object({ | ||
_text: Type.Integer() | ||
}), | ||
maxZoom: Type.Object({ | ||
_text: Type.Integer() | ||
}), | ||
tileType: Type.Object({ | ||
_text: Type.String() | ||
}), | ||
tileUpdate: Type.Optional(Type.Object({ | ||
_text: Type.String() | ||
})), | ||
url: Type.Optional(Type.Object({ | ||
_text: Type.String() | ||
})), | ||
backgroundColor: Type.Optional(Type.Object({ | ||
_text: Type.String() | ||
})), | ||
}) | ||
|
||
export default Type.Object({ | ||
customMapSource: BasemapMapSource | ||
}) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.