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

Proportional symbol #20

Open
ebocher opened this issue Nov 30, 2022 · 5 comments
Open

Proportional symbol #20

ebocher opened this issue Nov 30, 2022 · 5 comments

Comments

@ebocher
Copy link
Collaborator

ebocher commented Nov 30, 2022

Existing conformance classes required for this use case:

  • vector feature styling
  • viz/feature.pass (define conformance classes) 🧨
  • geometry selection 🧨
  • Geometry Manipulation Functions (centroid 🧨)
  • Interpolate function 🧨
  • Shape Graphics

Example stylesheet:

Below a CSS encoding to describe a proportionnal symbol map to display number of inhabitants on a regular grid (SUM_POP property).

*{
  stroke: grey;
  stroke-width: 1px;
  [SUM_POP>0] {
    geometry: centroid(the_geom);
    mark:   symbol(circle);
    mark-size: [Interpolate(
         SUM_POP,
         0, 10,
         30, 20,
         84, 100,
         'numeric',
         'linear')];
   :mark {
       fill: orange;
       fill-opacity: 0.2;
       stroke: black;
       stroke-width : 1px;
     }
  }
}

Describe any capability not already addressed by existing conformance classes:

Example image illustrating the portrayal use case:

proportional_symbol

@jerstlouis
Copy link
Member

[viz.pass = 1]
{
   stroke: { color: grey, width: 1 };
}
[viz.pass = 2][SUM_POP>0]
{
   geometry: centroid(the_geom);
   marker: Circle {
       fill: { color: orange, opacity: 0.2 };
       stroke: { color: black, width : 1 };
       radius: interpolate(SUM_POP, { 0: 10,  30: 20, 84: 100 }, numeric, linear);
   }
}

@oertz
Copy link
Collaborator

oertz commented Nov 30, 2022

[feature.pass = 1]
{
   stroke: { color: grey, width: 1 };
}
[feature.pass = 2][SUM_POP>0]
{
   geometry: centroid(the_geom);
   marker: Circle {
       fill: { color: orange, opacity: 0.2 };
       stroke: { color: black, width : 1 };
       radius: interpolate(SUM_POP, { 0: 10,  30: 20, 84: 100 }, numeric, linear);
   }
}

@oertz
Copy link
Collaborator

oertz commented Nov 30, 2022

*{
  stroke: grey;
  stroke-width: 1px;
}

[SUM_POP>0] {
    geometry: centroid(the_geom);
    mark:   symbol(circle);
    mark-size: [Interpolate(
         SUM_POP,
         0, 10,
         30, 20,
         84, 100,
         'numeric',
         'linear')];
   :mark {
       fill: orange;
       fill-opacity: 0.2;
       stroke: black;
       stroke-width : 1px;
     }
}

@maxcollombin
Copy link
Collaborator

maxcollombin commented Dec 8, 2022

Mapbox JSON encoding

NOTE:: MarkSymbolizer.wellKnownName is only partially supported by used parser: Only circle symbolizers are supported for the moment.

{
  "version": 8,
  "name": "Default Styler",
  "layers": [
    {
      "filter": [
        ">",
        "SUM_POP",
        0
      ],
      "id": "",
      "type": "line",
      "paint": {
        "line-color": "#808080"
      }
    },
    {
      "filter": [
        ">",
        "SUM_POP",
        0
      ],
      "id": "",
      "type": "circle",
      "paint": {
        "circle-radius": null,
        "circle-color": "#ffa500",
        "circle-opacity": 0.2
      }
    },
    {
      "filter": [
        "<=",
        "SUM_POP",
        0
      ],
      "id": "",
      "type": "line",
      "paint": {
        "line-color": "#808080"
      }
    }
  ]
}

@maxcollombin
Copy link
Collaborator

SLD encoding

<?xml version="1.0" encoding="UTF-8"?>
<sld:StyledLayerDescriptor
	xmlns="http://www.opengis.net/sld"
	xmlns:sld="http://www.opengis.net/sld"
	xmlns:gml="http://www.opengis.net/gml"
	xmlns:ogc="http://www.opengis.net/ogc" version="1.0.0">
	<sld:NamedLayer>
		<sld:Name>Default Styler</sld:Name>
		<sld:UserStyle>
			<sld:Name>Default Styler</sld:Name>
			<sld:FeatureTypeStyle>
				<sld:Name>name</sld:Name>
				<sld:Rule>
					<ogc:Filter>
						<ogc:PropertyIsGreaterThan>
							<ogc:PropertyName>SUM_POP</ogc:PropertyName>
							<ogc:Literal>0</ogc:Literal>
						</ogc:PropertyIsGreaterThan>
					</ogc:Filter>
					<sld:LineSymbolizer>
						<sld:Stroke>
							<sld:CssParameter name="stroke">#808080</sld:CssParameter>
						</sld:Stroke>
					</sld:LineSymbolizer>
					<sld:PointSymbolizer>
						<sld:Graphic>
							<sld:Mark>
								<sld:WellKnownName>circle</sld:WellKnownName>
								<sld:Fill>
									<sld:CssParameter name="fill">#ffa500</sld:CssParameter>
									<sld:CssParameter name="fill-opacity">0.2</sld:CssParameter>
								</sld:Fill>
								<sld:Stroke/>
							</sld:Mark>
							<sld:Size>
								<ogc:Function name="Interpolate">
									<ogc:PropertyName>SUM_POP</ogc:PropertyName>
									<ogc:Literal>0</ogc:Literal>
									<ogc:Literal>10</ogc:Literal>
									<ogc:Literal>30</ogc:Literal>
									<ogc:Literal>20</ogc:Literal>
									<ogc:Literal>84</ogc:Literal>
									<ogc:Literal>100</ogc:Literal>
									<ogc:Literal>numeric</ogc:Literal>
									<ogc:Literal>linear</ogc:Literal>
								</ogc:Function>
							</sld:Size>
						</sld:Graphic>
					</sld:PointSymbolizer>
				</sld:Rule>
				<sld:Rule>
					<ogc:Filter>
						<ogc:PropertyIsLessThanOrEqualTo>
							<ogc:PropertyName>SUM_POP</ogc:PropertyName>
							<ogc:Literal>0</ogc:Literal>
						</ogc:PropertyIsLessThanOrEqualTo>
					</ogc:Filter>
					<sld:LineSymbolizer>
						<sld:Stroke>
							<sld:CssParameter name="stroke">#808080</sld:CssParameter>
						</sld:Stroke>
					</sld:LineSymbolizer>
				</sld:Rule>
				<sld:VendorOption name="ruleEvaluation">first</sld:VendorOption>
			</sld:FeatureTypeStyle>
		</sld:UserStyle>
	</sld:NamedLayer>
</sld:StyledLayerDescriptor>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants