Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#6933: Enhance IconSymbolizer and Contrast enhancement #1

Merged
merged 2 commits into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@
},
"gammaValue": {
"type": "number"
},
"vendorOption": {
"$ref": "http://geostyler/geostyler-style.json#/definitions/VendorOption",
"description": "A VendorOption defines the algorithm to apply for Normalize contrast enhancement."
}
},
"type": "object"
Expand Down Expand Up @@ -300,6 +304,17 @@
"description": "A color defined as a hex-color string.",
"type": "string"
},
"format": {
"description": "The format (MIME type) of the image provided.",
"enum": [
"image/gif",
"image/jpeg",
"image/jpg",
"image/png",
"image/svg+xml"
],
"type": "string"
},
"haloBlur": {
"description": "The halo's fadeout distance towards the outside.",
"type": "number"
Expand Down Expand Up @@ -1113,6 +1128,26 @@
}
},
"type": "object"
},
"VendorOption": {
"description": "A VendorOption defines the algorithm to apply for Normalize contrast enhancement.",
"properties": {
"algorithm": {
"enum": [
"ClipToMinimumMaximum",
"ClipToZero",
"StretchToMinimumMaximum"
],
"type": "string"
},
"maxValue": {
"type": "number"
},
"minValue": {
"type": "number"
}
},
"type": "object"
}
},
"description": "The Style is the main interface and the root for all other interfaces.",
Expand Down
14 changes: 14 additions & 0 deletions style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ export interface IconSymbolizer extends BasePointSymbolizer {
* A path/URL to the icon image file.
*/
image?: string;
/**
* The format (MIME type) of the image provided.
*/
format?: `image/${'png' | 'jpg' | 'jpeg' | 'gif' | 'svg+xml'}`;
/**
* If true, the icon will be kept upright.
*/
Expand Down Expand Up @@ -549,12 +553,22 @@ export interface ColorMap {
extended?: boolean;
}

/**
* A VendorOption defines the algorithm to apply for Normalize contrast enhancement.
*/
export interface VendorOption {
algorithm?: 'StretchToMinimumMaximum' | 'ClipToMinimumMaximum' | 'ClipToZero';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that you are using nullable types for all the properties. If any of this is required I would remove the question mark.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, it is strange to see a sum type (alghoritm) as nullable, I would add a 'None' type if no alghoritm is possible, and remove the nullable

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the algorithm property alone is required. So I will update the property accordingly

minValue?: number;
maxValue?: number;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VendorOption seems a generic name but in this case is used only for ContrastEnhancement and it has a specific structure that match what the GeoServer expect.

Probably we should make this more specific:

export interface ContrastEnhancementVendorOption {
  algorithm?: 'StretchToMinimumMaximum' | 'ClipToMinimumMaximum' | 'ClipToZero';
  minValue?: number;
  maxValue?: number;
}
export interface ContrastEnhancementAlgorithm {
  name?: 'StretchToMinimumMaximum' | 'ClipToMinimumMaximum' | 'ClipToZero';
  minValue?: number;
  maxValue?: number;
}

export interface ContrastEnhancement {
  enhancementType?: 'normalize' | 'histogram';
  gammaValue?: number;
  algorithm?: ContrastEnhancementAlgorithm;
}

or more generic to be used in other context

export interface VendorProperty {
  name?: string;
  options?: any;
}

From the previous code it seems they prefer specific naming. My suggestions were more about the meaning of VendorOption itself that in this context seems to generic

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We agreed to change only the name of VendorOption to ContrastEnhancementVendorOption


/**
* A ContrastEnhancement defines how the contrast of image data should be enhanced.
*/
export interface ContrastEnhancement {
enhancementType?: 'normalize' | 'histogram';
gammaValue?: number;
vendorOption?: VendorOption;
}

/**
Expand Down