Use generic names for more types

This commit is contained in:
James Lyne 2021-07-24 04:06:19 +01:00
parent cba4b33e1a
commit bc38af3254
15 changed files with 153 additions and 178 deletions

View File

@ -24,13 +24,13 @@
<script lang="ts">
import {defineComponent, computed} from "@vue/runtime-core";
import {useStore} from "@/store";
import {DynmapMarkerSet} from "@/dynmap";
import Areas from "@/components/map/vector/Areas.vue";
import Circles from "@/components/map/vector/Circles.vue";
import Lines from "@/components/map/vector/Lines.vue";
import Markers from "@/components/map/vector/Markers.vue";
import LiveAtlasLeafletMap from "@/leaflet/LiveAtlasLeafletMap";
import LiveAtlasLayerGroup from "@/leaflet/layer/LiveAtlasLayerGroup";
import {LiveAtlasMarkerSet} from "@/index";
export default defineComponent({
components: {
@ -47,7 +47,7 @@ export default defineComponent({
},
markerSet: {
type: Object as () => DynmapMarkerSet,
type: Object as () => LiveAtlasMarkerSet,
required: true,
}
},

View File

@ -17,18 +17,18 @@
<script lang="ts">
import {defineComponent, computed, onMounted, onUnmounted, watch} from "@vue/runtime-core";
import {useStore} from "@/store";
import {DynmapArea, DynmapMarkerSet} from "@/dynmap";
import {ActionTypes} from "@/store/action-types";
import {createArea, updateArea} from "@/util/areas";
import {getPointConverter} from '@/util';
import LiveAtlasLayerGroup from "@/leaflet/layer/LiveAtlasLayerGroup";
import LiveAtlasPolygon from "@/leaflet/vector/LiveAtlasPolygon";
import LiveAtlasPolyline from "@/leaflet/vector/LiveAtlasPolyline";
import {LiveAtlasArea, LiveAtlasMarkerSet} from "@/index";
export default defineComponent({
props: {
set: {
type: Object as () => DynmapMarkerSet,
type: Object as () => LiveAtlasMarkerSet,
required: true,
},
layerGroup: {
@ -52,7 +52,7 @@ export default defineComponent({
createAreas = () => {
const converter = getPointConverter();
props.set.areas.forEach((area: DynmapArea, id: string) => {
props.set.areas.forEach((area: LiveAtlasArea, id: string) => {
const layer = createArea(area, converter);
layers.set(id, layer);
@ -83,7 +83,7 @@ export default defineComponent({
if(update.removed) {
deleteArea(update.id);
} else {
const layer = updateArea(layers.get(update.id), update.payload as DynmapArea, converter)
const layer = updateArea(layers.get(update.id), update.payload as LiveAtlasArea, converter)
if(!layers.has(update.id)) {
props.layerGroup.addLayer(layer);

View File

@ -17,18 +17,18 @@
<script lang="ts">
import {defineComponent, computed, onMounted, onUnmounted, watch} from "@vue/runtime-core";
import {useStore} from "@/store";
import {DynmapCircle, DynmapMarkerSet} from "@/dynmap";
import {ActionTypes} from "@/store/action-types";
import {createCircle, updateCircle} from "@/util/circles";
import {getPointConverter} from '@/util';
import LiveAtlasPolyline from "@/leaflet/vector/LiveAtlasPolyline";
import LiveAtlasPolygon from "@/leaflet/vector/LiveAtlasPolygon";
import LiveAtlasLayerGroup from "@/leaflet/layer/LiveAtlasLayerGroup";
import {LiveAtlasCircle, LiveAtlasMarkerSet} from "@/index";
export default defineComponent({
props: {
set: {
type: Object as () => DynmapMarkerSet,
type: Object as () => LiveAtlasMarkerSet,
required: true,
},
layerGroup: {
@ -52,7 +52,7 @@ export default defineComponent({
createCircles = () => {
const converter = getPointConverter();
props.set.circles.forEach((circle: DynmapCircle, id: string) => {
props.set.circles.forEach((circle: LiveAtlasCircle, id: string) => {
const layer = createCircle(circle, converter);
layers.set(id, layer);
@ -83,7 +83,7 @@ export default defineComponent({
if(update.removed) {
deleteCircle(update.id);
} else {
const layer = updateCircle(layers.get(update.id), update.payload as DynmapCircle, converter)
const layer = updateCircle(layers.get(update.id), update.payload as LiveAtlasCircle, converter)
if(!layers.has(update.id)) {
props.layerGroup.addLayer(layer);

View File

@ -17,17 +17,17 @@
<script lang="ts">
import {defineComponent, computed, onMounted, onUnmounted, watch} from "@vue/runtime-core";
import {useStore} from "@/store";
import {DynmapLine, DynmapMarkerSet} from "@/dynmap";
import {ActionTypes} from "@/store/action-types";
import {createLine, updateLine} from "@/util/lines";
import {getPointConverter} from '@/util';
import LiveAtlasPolyline from "@/leaflet/vector/LiveAtlasPolyline";
import LiveAtlasLayerGroup from "@/leaflet/layer/LiveAtlasLayerGroup";
import {LiveAtlasLine, LiveAtlasMarkerSet} from "@/index";
export default defineComponent({
props: {
set: {
type: Object as () => DynmapMarkerSet,
type: Object as () => LiveAtlasMarkerSet,
required: true,
},
layerGroup: {
@ -51,7 +51,7 @@ export default defineComponent({
createLines = () => {
const converter = getPointConverter();
props.set.lines.forEach((line: DynmapLine, id: string) => {
props.set.lines.forEach((line: LiveAtlasLine, id: string) => {
const layer = createLine(line, converter);
layers.set(id, layer);
@ -82,7 +82,7 @@ export default defineComponent({
if(update.removed) {
deleteLine(update.id);
} else {
const layer = updateLine(layers.get(update.id), update.payload as DynmapLine, converter)
const layer = updateLine(layers.get(update.id), update.payload as LiveAtlasLine, converter)
if(!layers.has(update.id)) {
props.layerGroup.addLayer(layer);

View File

@ -18,16 +18,16 @@
import {defineComponent, computed, onMounted, onUnmounted, watch} from "@vue/runtime-core";
import {Marker} from 'leaflet';
import {useStore} from "@/store";
import {DynmapMarker, DynmapMarkerSet} from "@/dynmap";
import {ActionTypes} from "@/store/action-types";
import {createMarker, updateMarker} from "@/util/markers";
import LiveAtlasLayerGroup from "@/leaflet/layer/LiveAtlasLayerGroup";
import {getPointConverter} from "@/util";
import {LiveAtlasMarker, LiveAtlasMarkerSet} from "@/index";
export default defineComponent({
props: {
set: {
type: Object as () => DynmapMarkerSet,
type: Object as () => LiveAtlasMarkerSet,
required: true,
},
layerGroup: {
@ -51,7 +51,7 @@ export default defineComponent({
createMarkers = () => {
const converter = getPointConverter();
props.set.markers.forEach((marker: DynmapMarker, id: string) => {
props.set.markers.forEach((marker: LiveAtlasMarker, id: string) => {
const layer = createMarker(marker, converter);
layers.set(id, layer);
@ -82,7 +82,7 @@ export default defineComponent({
if(update.removed) {
deleteMarker(update.id);
} else {
const layer = updateMarker(layers.get(update.id), update.payload as DynmapMarker, converter);
const layer = updateMarker(layers.get(update.id), update.payload as LiveAtlasMarker, converter);
if(!layers.has(update.id)) {
props.layerGroup.addLayer(layer);

100
src/dynmap.d.ts vendored
View File

@ -14,17 +14,10 @@
* limitations under the License.
*/
import {PathOptions, PointTuple, PolylineOptions} from "leaflet";
import {CoordinatesControlOptions} from "@/leaflet/control/CoordinatesControl";
import {LogoControlOptions} from "@/leaflet/control/LogoControl";
import {ClockControlOptions} from "@/leaflet/control/ClockControl";
import {
Coordinate,
LiveAtlasPlayer,
LiveAtlasServerMessageConfig,
LiveAtlasWorldDefinition,
LiveAtlasWorldState
} from "@/index";
import {LiveAtlasArea, LiveAtlasCircle, LiveAtlasLine, LiveAtlasMarker} from "@/index";
declare global {
// noinspection JSUnusedGlobalSymbols
@ -96,89 +89,6 @@ interface DynmapChatSendingConfig {
cooldown: number;
}
interface DynmapConfigurationResponse {
config: DynmapServerConfig,
messages: LiveAtlasServerMessageConfig,
worlds: Array<LiveAtlasWorldDefinition>,
components: DynmapComponentConfig,
loggedIn: boolean,
}
interface DynmapUpdateResponse {
worldState: LiveAtlasWorldState;
configHash: number;
playerCount: number;
players: Set<LiveAtlasPlayer>;
updates: DynmapUpdates;
timestamp: number;
}
interface DynmapMarkerSet {
id: string,
label: string;
hidden: boolean;
priority: number;
minZoom?: number;
maxZoom?: number;
showLabels?: boolean;
markers: Map<string, DynmapMarker>;
areas: Map<string, DynmapArea>;
lines: Map<string, DynmapLine>;
circles: Map<string, DynmapCircle>;
}
interface DynmapMarker {
dimensions: PointTuple;
icon: string;
label: string;
isHTML: boolean;
location: Coordinate;
minZoom?: number;
maxZoom?: number;
popupContent?: string;
}
interface DynmapArea {
style: PolylineOptions;
label: string;
isHTML: boolean;
x: Array<number>;
y: PointTuple;
z: Array<number>;
minZoom?: number;
maxZoom?: number;
popupContent?: string;
}
interface DynmapLine {
x: Array<number>;
y: Array<number>;
z: Array<number>;
style: PolylineOptions;
label: string;
isHTML: boolean;
minZoom?: number;
maxZoom?: number;
popupContent?: string;
}
interface DynmapCircle {
location: Coordinate;
radius: PointTuple;
style: PathOptions;
label: string;
isHTML: boolean;
minZoom?: number;
maxZoom?: number;
popupContent?: string;
}
interface DynmapUpdates {
markerSets: Map<string, DynmapMarkerSetUpdates>,
tiles: Array<DynmapTileUpdate>,
chat: Array<any> //TODO
}
interface DynmapMarkerSetUpdates {
markerUpdates: Array<DynmapMarkerUpdate>
areaUpdates: Array<DynmapAreaUpdate>
@ -202,19 +112,19 @@ interface DynmapUpdate {
}
interface DynmapMarkerUpdate extends DynmapUpdate {
payload?: DynmapMarker
payload?: LiveAtlasMarker
}
interface DynmapAreaUpdate extends DynmapUpdate {
payload?: DynmapArea
payload?: LiveAtlasArea
}
interface DynmapCircleUpdate extends DynmapUpdate {
payload?: DynmapCircle
payload?: LiveAtlasCircle
}
interface DynmapLineUpdate extends DynmapUpdate {
payload?: DynmapLine
payload?: LiveAtlasLine
}
interface DynmapTileUpdate {

61
src/index.d.ts vendored
View File

@ -1,6 +1,7 @@
import {State} from "@/store";
import {DynmapUrlConfig} from "@/dynmap";
import LiveAtlasMapDefinition from "@/model/LiveAtlasMapDefinition";
import {PathOptions, PointTuple, PolylineOptions} from "leaflet";
declare module "*.png" {
const value: any;
@ -156,3 +157,63 @@ interface LiveAtlasMapProvider {
sendChatMessage(message: string): void;
destroy(): void;
}
interface LiveAtlasMarkerSet {
id: string,
label: string;
hidden: boolean;
priority: number;
minZoom?: number;
maxZoom?: number;
showLabels?: boolean;
markers: Map<string, LiveAtlasMarker>;
areas: Map<string, LiveAtlasArea>;
lines: Map<string, LiveAtlasLine>;
circles: Map<string, LiveAtlasCircle>;
}
interface LiveAtlasMarker {
dimensions: PointTuple;
icon: string;
label: string;
isHTML: boolean;
location: Coordinate;
minZoom?: number;
maxZoom?: number;
popupContent?: string;
}
interface LiveAtlasArea {
style: PolylineOptions;
label: string;
isHTML: boolean;
x: Array<number>;
y: PointTuple;
z: Array<number>;
minZoom?: number;
maxZoom?: number;
popupContent?: string;
}
interface LiveAtlasLine {
x: Array<number>;
y: Array<number>;
z: Array<number>;
style: PolylineOptions;
label: string;
isHTML: boolean;
minZoom?: number;
maxZoom?: number;
popupContent?: string;
}
interface LiveAtlasCircle {
location: Coordinate;
radius: PointTuple;
style: PathOptions;
label: string;
isHTML: boolean;
minZoom?: number;
maxZoom?: number;
popupContent?: string;
}

View File

@ -15,18 +15,22 @@
*/
import {
LiveAtlasArea,
LiveAtlasCircle,
LiveAtlasDimension,
LiveAtlasDynmapServerDefinition, LiveAtlasPlayer, LiveAtlasServerDefinition,
LiveAtlasDynmapServerDefinition,
LiveAtlasLine,
LiveAtlasMarker,
LiveAtlasMarkerSet,
LiveAtlasPlayer,
LiveAtlasServerDefinition,
LiveAtlasServerMessageConfig,
LiveAtlasWorldDefinition
} from "@/index";
import {
DynmapArea, DynmapChat,
DynmapCircle,
DynmapChat,
DynmapComponentConfig,
DynmapLine,
DynmapMarker, DynmapMarkerSet, DynmapMarkerSetUpdates, DynmapServerConfig, DynmapTileUpdate, DynmapUpdate, DynmapUpdateResponse,
DynmapUpdates
DynmapMarkerSetUpdates, DynmapServerConfig, DynmapTileUpdate, DynmapUpdate
} from "@/dynmap";
import {useStore} from "@/store";
import LiveAtlasMapDefinition from "@/model/LiveAtlasMapDefinition";
@ -259,8 +263,8 @@ export default class DynmapMapProvider extends MapProvider {
}
}
private static buildMarkers(data: any): Map<string, DynmapMarker> {
const markers = Object.freeze(new Map()) as Map<string, DynmapMarker>;
private static buildMarkers(data: any): Map<string, LiveAtlasMarker> {
const markers = Object.freeze(new Map()) as Map<string, LiveAtlasMarker>;
for (const key in data) {
if (!Object.prototype.hasOwnProperty.call(data, key)) {
@ -273,7 +277,7 @@ export default class DynmapMapProvider extends MapProvider {
return markers;
}
private static buildMarker(marker: any): DynmapMarker {
private static buildMarker(marker: any): LiveAtlasMarker {
return {
label: marker.label || '',
location: {
@ -290,8 +294,8 @@ export default class DynmapMapProvider extends MapProvider {
};
}
private static buildAreas(data: any): Map<string, DynmapArea> {
const areas = Object.freeze(new Map()) as Map<string, DynmapArea>;
private static buildAreas(data: any): Map<string, LiveAtlasArea> {
const areas = Object.freeze(new Map()) as Map<string, LiveAtlasArea>;
for (const key in data) {
if (!Object.prototype.hasOwnProperty.call(data, key)) {
@ -304,7 +308,7 @@ export default class DynmapMapProvider extends MapProvider {
return areas;
}
private static buildArea(area: any): DynmapArea {
private static buildArea(area: any): LiveAtlasArea {
return {
style: {
color: area.color || '#ff0000',
@ -324,8 +328,8 @@ export default class DynmapMapProvider extends MapProvider {
};
}
private static buildLines(data: any): Map<string, DynmapLine> {
const lines = Object.freeze(new Map()) as Map<string, DynmapLine>;
private static buildLines(data: any): Map<string, LiveAtlasLine> {
const lines = Object.freeze(new Map()) as Map<string, LiveAtlasLine>;
for (const key in data) {
if (!Object.prototype.hasOwnProperty.call(data, key)) {
@ -338,7 +342,7 @@ export default class DynmapMapProvider extends MapProvider {
return lines;
}
private static buildLine(line: any): DynmapLine {
private static buildLine(line: any): LiveAtlasLine {
return {
x: line.x || [0, 0],
y: line.y || [0, 0],
@ -356,8 +360,8 @@ export default class DynmapMapProvider extends MapProvider {
};
}
private static buildCircles(data: any): Map<string, DynmapCircle> {
const circles = Object.freeze(new Map()) as Map<string, DynmapCircle>;
private static buildCircles(data: any): Map<string, LiveAtlasCircle> {
const circles = Object.freeze(new Map()) as Map<string, LiveAtlasCircle>;
for (const key in data) {
if (!Object.prototype.hasOwnProperty.call(data, key)) {
@ -370,7 +374,7 @@ export default class DynmapMapProvider extends MapProvider {
return circles;
}
private static buildCircle(circle: any): DynmapCircle {
private static buildCircle(circle: any): LiveAtlasCircle {
return {
location: {
x: circle.x || 0,
@ -612,7 +616,7 @@ export default class DynmapMapProvider extends MapProvider {
return json;
}
private async getMarkerSets(world: string): Promise<Map<string, DynmapMarkerSet>> {
private async getMarkerSets(world: string): Promise<Map<string, LiveAtlasMarkerSet>> {
const url = `${useStore().getters.serverConfig.dynmap.markers}_markers_/marker_${world}.json`;
if(this.markersAbort) {
@ -622,7 +626,7 @@ export default class DynmapMapProvider extends MapProvider {
this.markersAbort = new AbortController();
const response = await DynmapMapProvider.fetchJSON(url, this.markersAbort.signal);
const sets: Map<string, DynmapMarkerSet> = new Map();
const sets: Map<string, LiveAtlasMarkerSet> = new Map();
response.sets = response.sets || {};

View File

@ -21,11 +21,10 @@ import {ActionTypes} from "@/store/action-types";
import {Mutations} from "@/store/mutations";
import {
DynmapAreaUpdate, DynmapCircleUpdate, DynmapLineUpdate,
DynmapMarkerSet,
DynmapMarkerUpdate,
DynmapTileUpdate,
} from "@/dynmap";
import {LiveAtlasPlayer, LiveAtlasWorldDefinition} from "@/index";
import {LiveAtlasMarkerSet, LiveAtlasPlayer, LiveAtlasWorldDefinition} from "@/index";
type AugmentedActionContext = {
commit<K extends keyof Mutations>(
@ -47,7 +46,7 @@ export interface Actions {
[ActionTypes.SET_PLAYERS](
{commit}: AugmentedActionContext,
payload: Set<LiveAtlasPlayer>
):Promise<Map<string, DynmapMarkerSet>>
):Promise<Map<string, LiveAtlasMarkerSet>>
[ActionTypes.POP_MARKER_UPDATES](
{commit}: AugmentedActionContext,
payload: {markerSet: string, amount: number}

View File

@ -18,11 +18,7 @@ import {MutationTree} from "vuex";
import {MutationTypes} from "@/store/mutation-types";
import {State} from "@/store/state";
import {
DynmapArea,
DynmapCircle,
DynmapComponentConfig,
DynmapLine, DynmapMarker,
DynmapMarkerSet,
DynmapMarkerSetUpdates,
DynmapServerConfig, DynmapTileUpdate,
DynmapChat
@ -37,7 +33,12 @@ import {
LiveAtlasParsedUrl,
LiveAtlasGlobalConfig,
LiveAtlasGlobalMessageConfig,
LiveAtlasServerMessageConfig, LiveAtlasDynmapServerDefinition, LiveAtlasPlayer
LiveAtlasServerMessageConfig,
LiveAtlasDynmapServerDefinition,
LiveAtlasPlayer,
LiveAtlasCircle,
LiveAtlasLine,
LiveAtlasArea, LiveAtlasMarker, LiveAtlasMarkerSet
} from "@/index";
import DynmapMapProvider from "@/providers/DynmapMapProvider";
@ -55,7 +56,7 @@ export type Mutations<S = State> = {
[MutationTypes.SET_WORLDS](state: S, worlds: Array<LiveAtlasWorldDefinition>): void
[MutationTypes.CLEAR_WORLDS](state: S): void
[MutationTypes.SET_COMPONENTS](state: S, worlds: DynmapComponentConfig): void
[MutationTypes.SET_MARKER_SETS](state: S, worlds: Map<string, DynmapMarkerSet>): void
[MutationTypes.SET_MARKER_SETS](state: S, worlds: Map<string, LiveAtlasMarkerSet>): void
[MutationTypes.CLEAR_MARKER_SETS](state: S): void
[MutationTypes.ADD_WORLD](state: S, world: LiveAtlasWorldDefinition): void
[MutationTypes.SET_WORLD_STATE](state: S, worldState: LiveAtlasWorldState): void
@ -225,7 +226,7 @@ export const mutations: MutationTree<State> & Mutations = {
},
//Sets the existing marker sets from the last marker fetch
[MutationTypes.SET_MARKER_SETS](state: State, markerSets: Map<string, DynmapMarkerSet>) {
[MutationTypes.SET_MARKER_SETS](state: State, markerSets: Map<string, LiveAtlasMarkerSet>) {
state.markerSets.clear();
state.pendingSetUpdates.clear();
@ -269,10 +270,10 @@ export const mutations: MutationTree<State> & Mutations = {
priority: entry[1].payload.priority,
label: entry[1].payload.label,
hidden: entry[1].payload.hidden,
markers: Object.freeze(new Map()) as Map<string, DynmapMarker>,
areas: Object.freeze(new Map()) as Map<string, DynmapArea>,
circles: Object.freeze(new Map()) as Map<string, DynmapCircle>,
lines: Object.freeze(new Map()) as Map<string, DynmapLine>,
markers: Object.freeze(new Map()) as Map<string, LiveAtlasMarker>,
areas: Object.freeze(new Map()) as Map<string, LiveAtlasArea>,
circles: Object.freeze(new Map()) as Map<string, LiveAtlasCircle>,
lines: Object.freeze(new Map()) as Map<string, LiveAtlasLine>,
});
state.pendingSetUpdates.set(entry[0], {
@ -287,7 +288,7 @@ export const mutations: MutationTree<State> & Mutations = {
}
}
const set = state.markerSets.get(entry[0]) as DynmapMarkerSet,
const set = state.markerSets.get(entry[0]) as LiveAtlasMarkerSet,
setUpdates = state.pendingSetUpdates.get(entry[0]) as DynmapMarkerSetUpdates;
//Delete the set if it has been deleted
@ -312,7 +313,7 @@ export const mutations: MutationTree<State> & Mutations = {
if(update.removed) {
set.markers.delete(update.id);
} else {
set.markers.set(update.id, update.payload as DynmapMarker);
set.markers.set(update.id, update.payload as LiveAtlasMarker);
}
}
@ -320,7 +321,7 @@ export const mutations: MutationTree<State> & Mutations = {
if(update.removed) {
set.areas.delete(update.id);
} else {
set.areas.set(update.id, update.payload as DynmapArea);
set.areas.set(update.id, update.payload as LiveAtlasArea);
}
}
@ -328,7 +329,7 @@ export const mutations: MutationTree<State> & Mutations = {
if(update.removed) {
set.circles.delete(update.id);
} else {
set.circles.set(update.id, update.payload as DynmapCircle);
set.circles.set(update.id, update.payload as LiveAtlasCircle);
}
}
@ -336,7 +337,7 @@ export const mutations: MutationTree<State> & Mutations = {
if(update.removed) {
set.lines.delete(update.id);
} else {
set.lines.set(update.id, update.payload as DynmapLine);
set.lines.set(update.id, update.payload as LiveAtlasLine);
}
}

View File

@ -15,7 +15,7 @@
*/
import {
DynmapComponentConfig, DynmapMarkerSet, DynmapMarkerSetUpdates,
DynmapComponentConfig, DynmapMarkerSetUpdates,
DynmapServerConfig, DynmapTileUpdate,
DynmapChat
} from "@/dynmap";
@ -28,7 +28,7 @@ import {
LiveAtlasUIElement,
LiveAtlasWorldDefinition,
LiveAtlasParsedUrl,
LiveAtlasMessageConfig, LiveAtlasMapProvider, LiveAtlasPlayer
LiveAtlasMessageConfig, LiveAtlasMapProvider, LiveAtlasPlayer, LiveAtlasMarkerSet
} from "@/index";
import LiveAtlasMapDefinition from "@/model/LiveAtlasMapDefinition";
@ -46,7 +46,7 @@ export type State = {
maps: Map<string, LiveAtlasMapDefinition>;
players: Map<string, LiveAtlasPlayer>;
sortedPlayers: LiveAtlasSortedPlayers;
markerSets: Map<string, DynmapMarkerSet>;
markerSets: Map<string, LiveAtlasMarkerSet>;
chat: {
unread: number;

View File

@ -18,11 +18,11 @@
*/
import {LatLngExpression} from "leaflet";
import {DynmapArea} from "@/dynmap";
import LiveAtlasPolyline from "@/leaflet/vector/LiveAtlasPolyline";
import LiveAtlasPolygon from "@/leaflet/vector/LiveAtlasPolygon";
import {LiveAtlasArea} from "@/index";
export const createArea = (options: DynmapArea, converter: Function): LiveAtlasPolyline | LiveAtlasPolygon => {
export const createArea = (options: LiveAtlasArea, converter: Function): LiveAtlasPolyline | LiveAtlasPolygon => {
const outline = !options.style.fillOpacity || (options.style.fillOpacity <= 0),
points = getPoints(options, converter, outline),
area = outline ? new LiveAtlasPolyline(points, {
@ -42,7 +42,7 @@ export const createArea = (options: DynmapArea, converter: Function): LiveAtlasP
return area;
};
export const updateArea = (area: LiveAtlasPolyline | LiveAtlasPolygon | undefined, options: DynmapArea, converter: Function): LiveAtlasPolyline | LiveAtlasPolygon => {
export const updateArea = (area: LiveAtlasPolyline | LiveAtlasPolygon | undefined, options: LiveAtlasArea, converter: Function): LiveAtlasPolyline | LiveAtlasPolygon => {
const outline = !options.style || !options.style.fillOpacity || (options.style.fillOpacity <= 0) as boolean,
points = getPoints(options, converter, outline);
@ -88,7 +88,7 @@ const isStyleEqual = (oldStyle: any, newStyle: any) => {
&& (oldStyle.fillOpacity === newStyle.fillOpacity)
}
export const createPopup = (options: DynmapArea): HTMLElement => {
export const createPopup = (options: LiveAtlasArea): HTMLElement => {
const popup = document.createElement('span');
if (options.popupContent) {
@ -104,7 +104,7 @@ export const createPopup = (options: DynmapArea): HTMLElement => {
return popup;
};
export const getPoints = (options: DynmapArea, converter: Function, outline: boolean): LatLngExpression[] | LatLngExpression[][] => {
export const getPoints = (options: LiveAtlasArea, converter: Function, outline: boolean): LatLngExpression[] | LatLngExpression[][] => {
if (options.x.length === 2) { /* Only 2 points */
if (options.y[0] === options.y[1]) {
return get2DBoxPoints(options, converter, outline);
@ -120,7 +120,7 @@ export const getPoints = (options: DynmapArea, converter: Function, outline: boo
}
};
export const get3DBoxPoints = (options: DynmapArea, converter: Function): LatLngExpression[][] => {
export const get3DBoxPoints = (options: LiveAtlasArea, converter: Function): LatLngExpression[][] => {
const maxX = options.x[0],
minX = options.x[1],
maxY = options.y[0],
@ -163,7 +163,7 @@ export const get3DBoxPoints = (options: DynmapArea, converter: Function): LatLng
];
};
export const get2DBoxPoints = (options: DynmapArea, converter: Function, outline: boolean): LatLngExpression[] => {
export const get2DBoxPoints = (options: LiveAtlasArea, converter: Function, outline: boolean): LatLngExpression[] => {
const maxX = options.x[0],
minX = options.x[1],
minY = options.y[1],
@ -188,7 +188,7 @@ export const get2DBoxPoints = (options: DynmapArea, converter: Function, outline
}
};
export const get3DShapePoints = (options: DynmapArea, converter: Function): LatLngExpression[][] => {
export const get3DShapePoints = (options: LiveAtlasArea, converter: Function): LatLngExpression[][] => {
const toplist = [],
botlist = [],
polylist = [];
@ -213,7 +213,7 @@ export const get3DShapePoints = (options: DynmapArea, converter: Function): LatL
return polylist;
};
export const get2DShapePoints = (options: DynmapArea, converter: Function, outline: boolean): LatLngExpression[] => {
export const get2DShapePoints = (options: LiveAtlasArea, converter: Function, outline: boolean): LatLngExpression[] => {
const points = [];
for (let i = 0; i < options.x.length; i++) {

View File

@ -17,12 +17,12 @@
* limitations under the License.
*/
import {DynmapCircle} from "@/dynmap";
import {LatLngExpression} from "leaflet";
import LiveAtlasPolyline from "@/leaflet/vector/LiveAtlasPolyline";
import LiveAtlasPolygon from "@/leaflet/vector/LiveAtlasPolygon";
import {LiveAtlasCircle} from "@/index";
export const createCircle = (options: DynmapCircle, converter: Function): LiveAtlasPolyline | LiveAtlasPolygon => {
export const createCircle = (options: LiveAtlasCircle, converter: Function): LiveAtlasPolyline | LiveAtlasPolygon => {
const outline = !options.style.fillOpacity || (options.style.fillOpacity <= 0),
points = getCirclePoints(options, converter, outline),
circle = outline ? new LiveAtlasPolyline(points, {
@ -42,7 +42,7 @@ export const createCircle = (options: DynmapCircle, converter: Function): LiveAt
return circle;
};
export const updateCircle = (circle: LiveAtlasPolyline | LiveAtlasPolygon | undefined, options: DynmapCircle, converter: Function): LiveAtlasPolyline | LiveAtlasPolygon => {
export const updateCircle = (circle: LiveAtlasPolyline | LiveAtlasPolygon | undefined, options: LiveAtlasCircle, converter: Function): LiveAtlasPolyline | LiveAtlasPolygon => {
const outline = (options.style && options.style.fillOpacity && (options.style.fillOpacity <= 0)) as boolean,
points = getCirclePoints(options, converter, outline);
@ -60,7 +60,7 @@ export const updateCircle = (circle: LiveAtlasPolyline | LiveAtlasPolygon | unde
return circle;
}
export const createPopup = (options: DynmapCircle) => {
export const createPopup = (options: LiveAtlasCircle) => {
const popup = document.createElement('span');
if (options.popupContent) {
@ -76,7 +76,7 @@ export const createPopup = (options: DynmapCircle) => {
return popup;
}
export const getCirclePoints = (options: DynmapCircle, converter: Function, outline: boolean): LatLngExpression[] => {
export const getCirclePoints = (options: LiveAtlasCircle, converter: Function, outline: boolean): LatLngExpression[] => {
const points = [];
for(let i = 0; i < 360; i++) {

View File

@ -17,11 +17,11 @@
* limitations under the License.
*/
import {DynmapLine} from "@/dynmap";
import {LatLngExpression} from "leaflet";
import LiveAtlasPolyline from "@/leaflet/vector/LiveAtlasPolyline";
import {LiveAtlasLine} from "@/index";
export const createLine = (options: DynmapLine, converter: Function): LiveAtlasPolyline => {
export const createLine = (options: LiveAtlasLine, converter: Function): LiveAtlasPolyline => {
const points = getLinePoints(options, converter),
line = new LiveAtlasPolyline(points, {
...options.style,
@ -36,7 +36,7 @@ export const createLine = (options: DynmapLine, converter: Function): LiveAtlasP
return line;
};
export const updateLine = (line: LiveAtlasPolyline | undefined, options: DynmapLine, converter: Function): LiveAtlasPolyline => {
export const updateLine = (line: LiveAtlasPolyline | undefined, options: LiveAtlasLine, converter: Function): LiveAtlasPolyline => {
const points = getLinePoints(options, converter);
if (!line) {
@ -53,7 +53,7 @@ export const updateLine = (line: LiveAtlasPolyline | undefined, options: DynmapL
return line;
}
export const createPopup = (options: DynmapLine) => {
export const createPopup = (options: LiveAtlasLine) => {
const popup = document.createElement('span');
if (options.popupContent) {
@ -69,7 +69,7 @@ export const createPopup = (options: DynmapLine) => {
return popup;
}
export const getLinePoints = (options: DynmapLine, converter: Function): LatLngExpression[] => {
export const getLinePoints = (options: LiveAtlasLine, converter: Function): LatLngExpression[] => {
const points = [];
for(let i = 0; i < options.x.length; i++) {

View File

@ -18,11 +18,11 @@
*/
import {LeafletMouseEvent, Marker} from "leaflet";
import {DynmapMarker} from "@/dynmap";
import {GenericIcon} from "@/leaflet/icon/GenericIcon";
import {GenericMarker} from "@/leaflet/marker/GenericMarker";
import {LiveAtlasMarker} from "@/index";
export const createMarker = (options: DynmapMarker, converter: Function): Marker => {
export const createMarker = (options: LiveAtlasMarker, converter: Function): Marker => {
const marker = new GenericMarker(converter(options.location.x, options.location.y, options.location.z), {
icon: new GenericIcon({
icon: options.icon,
@ -45,7 +45,7 @@ export const createMarker = (options: DynmapMarker, converter: Function): Marker
return marker;
};
export const updateMarker = (marker: Marker | undefined, options: DynmapMarker, converter: Function): Marker => {
export const updateMarker = (marker: Marker | undefined, options: LiveAtlasMarker, converter: Function): Marker => {
if (!marker) {
return createMarker(options, converter);
}
@ -80,7 +80,7 @@ export const updateMarker = (marker: Marker | undefined, options: DynmapMarker,
return marker;
};
export const createPopup = (options: DynmapMarker) => {
export const createPopup = (options: LiveAtlasMarker) => {
const popup = document.createElement('span');
if (options.popupContent) {