Skip to content

Commit

Permalink
fix: add more esri types
Browse files Browse the repository at this point in the history
  • Loading branch information
bsteinemann committed Jun 20, 2024
1 parent e3aaac8 commit 990e19a
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 102 deletions.
4 changes: 3 additions & 1 deletion src/esri/types/CIMLayerAction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { CIMActivity, CIMCondition } from "./layers/CIMFeatureLayer";

type CIMActivity = {};
type CIMCondition = {};

export type CIMLayerAction = {
/**
Expand Down
1 change: 1 addition & 0 deletions src/esri/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

export * from './CIMLayerDocument';
export * from './labeling'
export * from './layers';
export * from './renderers';
74 changes: 74 additions & 0 deletions src/esri/types/labeling/CIMLabelClass.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { CIMObject } from "../CIMObject";
import { CIMSymbolReference } from "./CIMSymbolReference";

type LabelExpressionEngine = {};
type FeaturesToLabel = {};
type CIMMaplexLabelPlacementProperties = {};
type CIMStandardLabelPlacementProperties = {};

/**
* Represents a label class which describes how to generate a set of text labels from a group of features in a feature layer.
*
*/
export type CIMLabelClass = CIMObject & {
/**
* Gets or sets the human readable text title that describes the label expression.
*/
expressionTitle?: null | string;
/**
* Gets or sets the label expression.
*/
expression?: null | string;
/**
* Gets or sets the label expression engine (the language the expression is written in).
*/
expressionEngine?: LabelExpressionEngine;
/**
* Gets or sets a parameter indicating which features to label.
*/
featuresToLabel?: FeaturesToLabel;
/**
* Gets or sets the Maplex placement properties which are used when the map uses the Maplex label engine.
*/
maplexLabelPlacementProperties?: null | CIMMaplexLabelPlacementProperties;
/**
* Gets or sets the maximum scale for labeling (set as the denominator of the scale's representative fraction).
*/
maximumScale?: number;
/**
* Gets or sets the minimum scale for labeling (set as the denominator of the scale's representative fraction).
*/
minimumScale?: number;
/**
* Gets or sets the name of the label class.
*/
name?: null | string;
/**
* Gets or sets the priority of the label class.
*/
priority?: number;
/**
* Gets or sets the standard placement properties which are used when the map uses the standard label engine.
*/
standardLabelPlacementProperties?: null | CIMStandardLabelPlacementProperties;
/**
* Gets or sets the text symbol of the label class.
*/
textSymbol?: null | CIMSymbolReference;
/**
* Gets or sets a value indicating whether or not to use coded value domain descriptions when labeling.
*/
useCodedValue?: boolean;
/**
* Gets or sets the SQL where clause of which features to label with this label class.
*/
whereClause?: null | string;
/**
* Gets or sets a value indicating whether this label class is visible.
*/
visibility?: boolean;
/**
* Gets or sets the ID of the label class. This property is only used in the context of annotation.
*/
id?: number;
}
46 changes: 46 additions & 0 deletions src/esri/types/labeling/CIMSymbolReference.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
type CIMPrimitiveOverride = {};
type CIMScaleDependentSizeVariation = {};
type CIMSymbol = {};

/**
* Represents a symbol reference.
*
*/
export type CIMSymbolReference = {
/**
* Gets or sets the primitive overrides. Typically set by renderers at draw time.
*/
primitiveOverrides?: CIMPrimitiveOverride[] | null;
/**
* Gets or sets the style path. Reserved for future use.
*/
stylePath?: null | string;
/**
* Gets or sets the symbol.
*/
symbol?: null | CIMSymbol;
/**
* Gets or sets the symbol name.
*/
symbolName?: null | string;
/**
* Gets or sets the minimum scale range the symbol reference should be displayed at.
*/
minScale?: number;
/**
* Gets or sets the maximum scale range the symbol reference should be displayed at.
*/
maxScale?: number;
/**
* Gets or sets an array of scale dependent sizes.
*/
scaleDependentSizeVariation?: CIMScaleDependentSizeVariation[] | null;
/**
* Gets or sets the minimum distance at which symbols are visible. Objects closer than this don't get rendered.
*/
minDistance?: number;
/**
* Gets or sets the maximum distance at which symbols are visible. Objects beyond this point don't get rendered.
*/
maxDistance?: number;
}
2 changes: 2 additions & 0 deletions src/esri/types/labeling/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './CIMLabelClass';
export * from './CIMSymbolReference';
88 changes: 2 additions & 86 deletions src/esri/types/layers/CIMFeatureLayer.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import { CIMLayerAction } from "../CIMLayerAction";
import { CIMLayerDefinition } from "./CIMLayerDefinition";
import { CIMRenderer } from "../renderers/CIMRenderer";
import { CIMLabelClass } from "../labeling/CIMLabelClass";
import { CIMSymbolReference } from "../labeling/CIMSymbolReference";

type CIMDataConnection = {};
type LabelExpressionEngine = {};
type CIMSymbolLayerMasking = {};
type FeaturesToLabel = {};
type CIMFeatureExtrusion = {};
type CIMSymbolLayerDrawing = {};
type CIMFeatureReduction = {};
type CIMEditingTemplate = {};
type CIMFeatureTable = {};
type CIMHtmlPopupFormat = {};
type CIMColor = {};
type CIMSymbolReference = {};
type CIMPageDefinition = {};
type FeatureCacheType = {};
type CIMDisplayFilter = {};
Expand All @@ -29,8 +28,6 @@ type CIMPopupInfo = {};
type CIMChart = {};
type EsriTimeUnits = {};
type CIMStringMap = {};
type CIMMaplexLabelPlacementProperties = {};
type CIMStandardLabelPlacementProperties = {};

export type CIMFeatureLayer = CIMLayerDefinition & {
/**
Expand Down Expand Up @@ -323,84 +320,3 @@ export type CIMFeatureLayer = CIMLayerDefinition & {
*/
sourcePortalUrl?: null | string;
};
/**
* Represents a layer action.
*
*/

/**
* Represents activity.
*
*/
export interface CIMActivity {}
/**
* Represents a condition.
*/
export interface CIMCondition {}

/**
* Represents a label class which describes how to generate a set of text labels from a group of features in a feature layer.
*
*/
export interface CIMLabelClass {
/**
* Gets or sets the human readable text title that describes the label expression.
*/
expressionTitle?: null | string;
/**
* Gets or sets the label expression.
*/
expression?: null | string;
/**
* Gets or sets the label expression engine (the language the expression is written in).
*/
expressionEngine?: LabelExpressionEngine;
/**
* Gets or sets a parameter indicating which features to label.
*/
featuresToLabel?: FeaturesToLabel;
/**
* Gets or sets the Maplex placement properties which are used when the map uses the Maplex label engine.
*/
maplexLabelPlacementProperties?: null | CIMMaplexLabelPlacementProperties;
/**
* Gets or sets the maximum scale for labeling (set as the denominator of the scale's representative fraction).
*/
maximumScale?: number;
/**
* Gets or sets the minimum scale for labeling (set as the denominator of the scale's representative fraction).
*/
minimumScale?: number;
/**
* Gets or sets the name of the label class.
*/
name?: null | string;
/**
* Gets or sets the priority of the label class.
*/
priority?: number;
/**
* Gets or sets the standard placement properties which are used when the map uses the standard label engine.
*/
standardLabelPlacementProperties?: null | CIMStandardLabelPlacementProperties;
/**
* Gets or sets the text symbol of the label class.
*/
textSymbol?: null | CIMSymbolReference;
/**
* Gets or sets a value indicating whether or not to use coded value domain descriptions when labeling.
*/
useCodedValue?: boolean;
/**
* Gets or sets the SQL where clause of which features to label with this label class.
*/
whereClause?: null | string;
/**
* Gets or sets a value indicating whether this label class is visible.
*/
visibility?: boolean;
/**
* Gets or sets the ID of the label class. This property is only used in the context of annotation.
*/
id?: number;
}
2 changes: 1 addition & 1 deletion src/esri/types/layers/CIMRasterLayer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CIMLayerDefinition } from "./layers/CIMLayerDefinition";
import { CIMLayerDefinition } from "./CIMLayerDefinition";

export type CIMRasterLayer = CIMLayerDefinition & {

Expand Down
30 changes: 16 additions & 14 deletions src/toGeostyler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {convertExpression, convertWhereClause, processRotationExpression} from "
import {Group, LabelClass, Options, Rule, Symbolizer} from "./badTypes.ts";
import {extractFillColor, extractFontWeight, ptToPxProp, WARNINGS,} from "./toGeostylerUtils.ts";
import {processSymbolReference} from "./processSymbolReference.ts";
import { CIMLayerDocument, CIMLayerDefinition, CIMRenderer } from './esri/types';
import { CIMLayerDocument, CIMLayerDefinition, CIMRenderer, CIMFeatureLayer } from './esri/types';
import { CIMLabelClass } from './esri/types/labeling/CIMLabelClass.ts';


const usedIcons: string[] = []
Expand All @@ -14,20 +15,21 @@ export const convert = (layerDocument: CIMLayerDocument , options=undefined): an
}

const processLayer = (layer: CIMLayerDefinition, options: Options = {}): Style => {
const style: Style = {
name: layer.name,
rules: []
};
if (layer.type === "CIMFeatureLayer") {
style.rules = processFeatureLayer(layer, options);
} else if (layer.type === "CIMRasterLayer") {
style.rules = processRasterLayer(layer);
}
const style: Style = {
name: layer.name,
rules: []
};

return style;
if (layer.type === "CIMFeatureLayer") {
style.rules = processFeatureLayer(layer, options);
} else if (layer.type === "CIMRasterLayer") {
style.rules = processRasterLayer(layer);
}

return style;
}

const processFeatureLayer = (layer: any, options: Options = {}):FIXMERULE[] => {
const processFeatureLayer = (layer: CIMFeatureLayer, options: Options = {}):FIXMERULE[] => {
const toLowerCase = options.toLowerCase || false;
const renderer = layer.renderer!;
const rules: Rule[] = [];
Expand Down Expand Up @@ -143,8 +145,8 @@ const processClassBreaksRenderer = (renderer: any, options: Options = {}): Rule[
return rules;
}

const processLabelClass = (labelClass: LabelClass, toLowerCase: boolean = false): Rule => {
const textSymbol = labelClass.textSymbol.symbol;
const processLabelClass = (labelClass: CIMLabelClass, toLowerCase: boolean = false): Rule => {
const textSymbol = labelClass.textSymbol?.symbol;
const expression = convertExpression(labelClass.expression, labelClass.expressionEngine, toLowerCase);
const fontFamily = textSymbol.fontFamilyName || "Arial";
const fontSize = ptToPxProp(textSymbol, "height", 12, true);
Expand Down

0 comments on commit 990e19a

Please sign in to comment.