[core] Implement data-driven styling for {text,icon}-{color,opacity,halo-color,halo-blur,halo-width} (#7939)

* Add symbol dds attributes and adapt style code generation

* Update to mapbox-gl-js/master

* Refactor SymbolFeature as a subclass of GeometryTileFeature

Prepares for enabling DDS on symbol paint properties by allowing the
SymbolFeatures, which we keep around after constructing SymbolLayout,
to be used in evaluating data-driven paint properties later in the
layout process.

* Draft approach for splitting icon/text paint properties

The `Program` types are set up to bind GL attributes to each of the
data-driven paint properties specified in the `PaintProperties` type
provided.  Since `SymbolPaintProperties` specifies both `Text*` and
`Icon*` properties, the symbolIcon, symbolIconSDF, and symbolGlyph
programs each attempt to bind roughly double the number of attributes
that they actually need.

This change addresses this by:
- Adding the more specific `IconPaintProperties` and `TextPaintProperties` types, which are subsets of the full `SymbolPaintProperties`.
- The symbol layer continues to use its `SymbolPaintProperties paint` member to track layer property state, but it provides helpers that construct objects of each the specific `{Icon,Text}PaintProperties::Evaluated` type, for use by the painter.
- The three symbol programs instantiate `Program<>` using the appropriate `{Icon,Text}PaintProperties` type.

* check in generated style code

* Populate paint buffers for symbol DDS properties

* Address first round of review comments

* Refactor VectorTile{Layer,Feature} to explicitly share data

* Update submodule
This commit is contained in:
Anand Thakker
2017-02-28 19:54:24 -08:00
committed by GitHub
parent c3ed1f51ca
commit f901e776b3
31 changed files with 1982 additions and 475 deletions

View File

@@ -1597,6 +1597,112 @@ public class SymbolLayerTest extends BaseStyleTest {
assertEquals(1, ((ExponentialStops) layer.getIconOpacity().getFunction().getStops()).size());
}
@Test
public void testIconOpacityAsIdentitySourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("icon-opacity");
assertNotNull(layer);
// Set
layer.setProperties(
iconOpacity(property("FeaturePropertyA", Stops.<Float>identity()))
);
// Verify
assertNotNull(layer.getIconOpacity());
assertNotNull(layer.getIconOpacity().getFunction());
assertEquals(SourceFunction.class, layer.getIconOpacity().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconOpacity().getFunction()).getProperty());
assertEquals(IdentityStops.class, layer.getIconOpacity().getFunction().getStops().getClass());
}
@Test
public void testIconOpacityAsExponentialSourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("icon-opacity");
assertNotNull(layer);
// Set
layer.setProperties(
iconOpacity(
property(
"FeaturePropertyA",
exponential(
stop(0.3f, iconOpacity(0.3f))
).withBase(0.5f)
)
)
);
// Verify
assertNotNull(layer.getIconOpacity());
assertNotNull(layer.getIconOpacity().getFunction());
assertEquals(SourceFunction.class, layer.getIconOpacity().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconOpacity().getFunction()).getProperty());
assertEquals(ExponentialStops.class, layer.getIconOpacity().getFunction().getStops().getClass());
}
@Test
public void testIconOpacityAsCategoricalSourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("icon-opacity");
assertNotNull(layer);
// Set
layer.setProperties(
iconOpacity(
property(
"FeaturePropertyA",
categorical(
stop(1.0f, iconOpacity(0.3f))
)
).withDefaultValue(0.3f)
)
);
// Verify
assertNotNull(layer.getIconOpacity());
assertNotNull(layer.getIconOpacity().getFunction());
assertEquals(SourceFunction.class, layer.getIconOpacity().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconOpacity().getFunction()).getProperty());
assertEquals(CategoricalStops.class, layer.getIconOpacity().getFunction().getStops().getClass());
assertEquals(0.3f, ((SourceFunction) layer.getIconOpacity().getFunction()).getDefaultValue());
}
@Test
public void testIconOpacityAsCompositeFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("icon-opacity");
assertNotNull(layer);
// Set
layer.setProperties(
iconOpacity(
composite(
"FeaturePropertyA",
exponential(
stop(0, 0.3f, iconOpacity(0.9f))
).withBase(0.5f)
).withDefaultValue(0.3f)
)
);
// Verify
assertNotNull(layer.getIconOpacity());
assertNotNull(layer.getIconOpacity().getFunction());
assertEquals(CompositeFunction.class, layer.getIconOpacity().getFunction().getClass());
assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getIconOpacity().getFunction()).getProperty());
assertEquals(ExponentialStops.class, layer.getIconOpacity().getFunction().getStops().getClass());
assertEquals(1, ((ExponentialStops) layer.getIconOpacity().getFunction().getStops()).size());
ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops =
(ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getIconOpacity().getFunction().getStops();
Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next();
assertEquals(0f, stop.in.zoom, 0.001);
assertEquals(0.3f, stop.in.value, 0.001f);
assertEquals(0.9f, stop.out, 0.001f);
}
@Test
public void testIconColorAsConstant() {
checkViewIsDisplayed(R.id.mapView);
@@ -1634,6 +1740,77 @@ public class SymbolLayerTest extends BaseStyleTest {
assertEquals(1, ((ExponentialStops) layer.getIconColor().getFunction().getStops()).size());
}
@Test
public void testIconColorAsIdentitySourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("icon-color");
assertNotNull(layer);
// Set
layer.setProperties(
iconColor(property("FeaturePropertyA", Stops.<String>identity()))
);
// Verify
assertNotNull(layer.getIconColor());
assertNotNull(layer.getIconColor().getFunction());
assertEquals(SourceFunction.class, layer.getIconColor().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconColor().getFunction()).getProperty());
assertEquals(IdentityStops.class, layer.getIconColor().getFunction().getStops().getClass());
}
@Test
public void testIconColorAsExponentialSourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("icon-color");
assertNotNull(layer);
// Set
layer.setProperties(
iconColor(
property(
"FeaturePropertyA",
exponential(
stop(Color.RED, iconColor(Color.RED))
).withBase(0.5f)
)
)
);
// Verify
assertNotNull(layer.getIconColor());
assertNotNull(layer.getIconColor().getFunction());
assertEquals(SourceFunction.class, layer.getIconColor().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconColor().getFunction()).getProperty());
assertEquals(ExponentialStops.class, layer.getIconColor().getFunction().getStops().getClass());
}
@Test
public void testIconColorAsCategoricalSourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("icon-color");
assertNotNull(layer);
// Set
layer.setProperties(
iconColor(
property(
"FeaturePropertyA",
categorical(
stop("valueA", iconColor(Color.RED))
)
)
)
);
// Verify
assertNotNull(layer.getIconColor());
assertNotNull(layer.getIconColor().getFunction());
assertEquals(SourceFunction.class, layer.getIconColor().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconColor().getFunction()).getProperty());
assertEquals(CategoricalStops.class, layer.getIconColor().getFunction().getStops().getClass());
}
@Test
public void testIconColorAsIntConstant() {
checkViewIsDisplayed(R.id.mapView);
@@ -1682,6 +1859,77 @@ public class SymbolLayerTest extends BaseStyleTest {
assertEquals(1, ((ExponentialStops) layer.getIconHaloColor().getFunction().getStops()).size());
}
@Test
public void testIconHaloColorAsIdentitySourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("icon-halo-color");
assertNotNull(layer);
// Set
layer.setProperties(
iconHaloColor(property("FeaturePropertyA", Stops.<String>identity()))
);
// Verify
assertNotNull(layer.getIconHaloColor());
assertNotNull(layer.getIconHaloColor().getFunction());
assertEquals(SourceFunction.class, layer.getIconHaloColor().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloColor().getFunction()).getProperty());
assertEquals(IdentityStops.class, layer.getIconHaloColor().getFunction().getStops().getClass());
}
@Test
public void testIconHaloColorAsExponentialSourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("icon-halo-color");
assertNotNull(layer);
// Set
layer.setProperties(
iconHaloColor(
property(
"FeaturePropertyA",
exponential(
stop(Color.RED, iconHaloColor(Color.RED))
).withBase(0.5f)
)
)
);
// Verify
assertNotNull(layer.getIconHaloColor());
assertNotNull(layer.getIconHaloColor().getFunction());
assertEquals(SourceFunction.class, layer.getIconHaloColor().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloColor().getFunction()).getProperty());
assertEquals(ExponentialStops.class, layer.getIconHaloColor().getFunction().getStops().getClass());
}
@Test
public void testIconHaloColorAsCategoricalSourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("icon-halo-color");
assertNotNull(layer);
// Set
layer.setProperties(
iconHaloColor(
property(
"FeaturePropertyA",
categorical(
stop("valueA", iconHaloColor(Color.RED))
)
)
)
);
// Verify
assertNotNull(layer.getIconHaloColor());
assertNotNull(layer.getIconHaloColor().getFunction());
assertEquals(SourceFunction.class, layer.getIconHaloColor().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloColor().getFunction()).getProperty());
assertEquals(CategoricalStops.class, layer.getIconHaloColor().getFunction().getStops().getClass());
}
@Test
public void testIconHaloColorAsIntConstant() {
checkViewIsDisplayed(R.id.mapView);
@@ -1730,6 +1978,112 @@ public class SymbolLayerTest extends BaseStyleTest {
assertEquals(1, ((ExponentialStops) layer.getIconHaloWidth().getFunction().getStops()).size());
}
@Test
public void testIconHaloWidthAsIdentitySourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("icon-halo-width");
assertNotNull(layer);
// Set
layer.setProperties(
iconHaloWidth(property("FeaturePropertyA", Stops.<Float>identity()))
);
// Verify
assertNotNull(layer.getIconHaloWidth());
assertNotNull(layer.getIconHaloWidth().getFunction());
assertEquals(SourceFunction.class, layer.getIconHaloWidth().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloWidth().getFunction()).getProperty());
assertEquals(IdentityStops.class, layer.getIconHaloWidth().getFunction().getStops().getClass());
}
@Test
public void testIconHaloWidthAsExponentialSourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("icon-halo-width");
assertNotNull(layer);
// Set
layer.setProperties(
iconHaloWidth(
property(
"FeaturePropertyA",
exponential(
stop(0.3f, iconHaloWidth(0.3f))
).withBase(0.5f)
)
)
);
// Verify
assertNotNull(layer.getIconHaloWidth());
assertNotNull(layer.getIconHaloWidth().getFunction());
assertEquals(SourceFunction.class, layer.getIconHaloWidth().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloWidth().getFunction()).getProperty());
assertEquals(ExponentialStops.class, layer.getIconHaloWidth().getFunction().getStops().getClass());
}
@Test
public void testIconHaloWidthAsCategoricalSourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("icon-halo-width");
assertNotNull(layer);
// Set
layer.setProperties(
iconHaloWidth(
property(
"FeaturePropertyA",
categorical(
stop(1.0f, iconHaloWidth(0.3f))
)
).withDefaultValue(0.3f)
)
);
// Verify
assertNotNull(layer.getIconHaloWidth());
assertNotNull(layer.getIconHaloWidth().getFunction());
assertEquals(SourceFunction.class, layer.getIconHaloWidth().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloWidth().getFunction()).getProperty());
assertEquals(CategoricalStops.class, layer.getIconHaloWidth().getFunction().getStops().getClass());
assertEquals(0.3f, ((SourceFunction) layer.getIconHaloWidth().getFunction()).getDefaultValue());
}
@Test
public void testIconHaloWidthAsCompositeFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("icon-halo-width");
assertNotNull(layer);
// Set
layer.setProperties(
iconHaloWidth(
composite(
"FeaturePropertyA",
exponential(
stop(0, 0.3f, iconHaloWidth(0.9f))
).withBase(0.5f)
).withDefaultValue(0.3f)
)
);
// Verify
assertNotNull(layer.getIconHaloWidth());
assertNotNull(layer.getIconHaloWidth().getFunction());
assertEquals(CompositeFunction.class, layer.getIconHaloWidth().getFunction().getClass());
assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getIconHaloWidth().getFunction()).getProperty());
assertEquals(ExponentialStops.class, layer.getIconHaloWidth().getFunction().getStops().getClass());
assertEquals(1, ((ExponentialStops) layer.getIconHaloWidth().getFunction().getStops()).size());
ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops =
(ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getIconHaloWidth().getFunction().getStops();
Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next();
assertEquals(0f, stop.in.zoom, 0.001);
assertEquals(0.3f, stop.in.value, 0.001f);
assertEquals(0.9f, stop.out, 0.001f);
}
@Test
public void testIconHaloBlurAsConstant() {
checkViewIsDisplayed(R.id.mapView);
@@ -1767,6 +2121,112 @@ public class SymbolLayerTest extends BaseStyleTest {
assertEquals(1, ((ExponentialStops) layer.getIconHaloBlur().getFunction().getStops()).size());
}
@Test
public void testIconHaloBlurAsIdentitySourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("icon-halo-blur");
assertNotNull(layer);
// Set
layer.setProperties(
iconHaloBlur(property("FeaturePropertyA", Stops.<Float>identity()))
);
// Verify
assertNotNull(layer.getIconHaloBlur());
assertNotNull(layer.getIconHaloBlur().getFunction());
assertEquals(SourceFunction.class, layer.getIconHaloBlur().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloBlur().getFunction()).getProperty());
assertEquals(IdentityStops.class, layer.getIconHaloBlur().getFunction().getStops().getClass());
}
@Test
public void testIconHaloBlurAsExponentialSourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("icon-halo-blur");
assertNotNull(layer);
// Set
layer.setProperties(
iconHaloBlur(
property(
"FeaturePropertyA",
exponential(
stop(0.3f, iconHaloBlur(0.3f))
).withBase(0.5f)
)
)
);
// Verify
assertNotNull(layer.getIconHaloBlur());
assertNotNull(layer.getIconHaloBlur().getFunction());
assertEquals(SourceFunction.class, layer.getIconHaloBlur().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloBlur().getFunction()).getProperty());
assertEquals(ExponentialStops.class, layer.getIconHaloBlur().getFunction().getStops().getClass());
}
@Test
public void testIconHaloBlurAsCategoricalSourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("icon-halo-blur");
assertNotNull(layer);
// Set
layer.setProperties(
iconHaloBlur(
property(
"FeaturePropertyA",
categorical(
stop(1.0f, iconHaloBlur(0.3f))
)
).withDefaultValue(0.3f)
)
);
// Verify
assertNotNull(layer.getIconHaloBlur());
assertNotNull(layer.getIconHaloBlur().getFunction());
assertEquals(SourceFunction.class, layer.getIconHaloBlur().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloBlur().getFunction()).getProperty());
assertEquals(CategoricalStops.class, layer.getIconHaloBlur().getFunction().getStops().getClass());
assertEquals(0.3f, ((SourceFunction) layer.getIconHaloBlur().getFunction()).getDefaultValue());
}
@Test
public void testIconHaloBlurAsCompositeFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("icon-halo-blur");
assertNotNull(layer);
// Set
layer.setProperties(
iconHaloBlur(
composite(
"FeaturePropertyA",
exponential(
stop(0, 0.3f, iconHaloBlur(0.9f))
).withBase(0.5f)
).withDefaultValue(0.3f)
)
);
// Verify
assertNotNull(layer.getIconHaloBlur());
assertNotNull(layer.getIconHaloBlur().getFunction());
assertEquals(CompositeFunction.class, layer.getIconHaloBlur().getFunction().getClass());
assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getIconHaloBlur().getFunction()).getProperty());
assertEquals(ExponentialStops.class, layer.getIconHaloBlur().getFunction().getStops().getClass());
assertEquals(1, ((ExponentialStops) layer.getIconHaloBlur().getFunction().getStops()).size());
ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops =
(ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getIconHaloBlur().getFunction().getStops();
Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next();
assertEquals(0f, stop.in.zoom, 0.001);
assertEquals(0.3f, stop.in.value, 0.001f);
assertEquals(0.9f, stop.out, 0.001f);
}
@Test
public void testIconTranslateAsConstant() {
checkViewIsDisplayed(R.id.mapView);
@@ -1877,6 +2337,112 @@ public class SymbolLayerTest extends BaseStyleTest {
assertEquals(1, ((ExponentialStops) layer.getTextOpacity().getFunction().getStops()).size());
}
@Test
public void testTextOpacityAsIdentitySourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("text-opacity");
assertNotNull(layer);
// Set
layer.setProperties(
textOpacity(property("FeaturePropertyA", Stops.<Float>identity()))
);
// Verify
assertNotNull(layer.getTextOpacity());
assertNotNull(layer.getTextOpacity().getFunction());
assertEquals(SourceFunction.class, layer.getTextOpacity().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextOpacity().getFunction()).getProperty());
assertEquals(IdentityStops.class, layer.getTextOpacity().getFunction().getStops().getClass());
}
@Test
public void testTextOpacityAsExponentialSourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("text-opacity");
assertNotNull(layer);
// Set
layer.setProperties(
textOpacity(
property(
"FeaturePropertyA",
exponential(
stop(0.3f, textOpacity(0.3f))
).withBase(0.5f)
)
)
);
// Verify
assertNotNull(layer.getTextOpacity());
assertNotNull(layer.getTextOpacity().getFunction());
assertEquals(SourceFunction.class, layer.getTextOpacity().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextOpacity().getFunction()).getProperty());
assertEquals(ExponentialStops.class, layer.getTextOpacity().getFunction().getStops().getClass());
}
@Test
public void testTextOpacityAsCategoricalSourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("text-opacity");
assertNotNull(layer);
// Set
layer.setProperties(
textOpacity(
property(
"FeaturePropertyA",
categorical(
stop(1.0f, textOpacity(0.3f))
)
).withDefaultValue(0.3f)
)
);
// Verify
assertNotNull(layer.getTextOpacity());
assertNotNull(layer.getTextOpacity().getFunction());
assertEquals(SourceFunction.class, layer.getTextOpacity().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextOpacity().getFunction()).getProperty());
assertEquals(CategoricalStops.class, layer.getTextOpacity().getFunction().getStops().getClass());
assertEquals(0.3f, ((SourceFunction) layer.getTextOpacity().getFunction()).getDefaultValue());
}
@Test
public void testTextOpacityAsCompositeFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("text-opacity");
assertNotNull(layer);
// Set
layer.setProperties(
textOpacity(
composite(
"FeaturePropertyA",
exponential(
stop(0, 0.3f, textOpacity(0.9f))
).withBase(0.5f)
).withDefaultValue(0.3f)
)
);
// Verify
assertNotNull(layer.getTextOpacity());
assertNotNull(layer.getTextOpacity().getFunction());
assertEquals(CompositeFunction.class, layer.getTextOpacity().getFunction().getClass());
assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getTextOpacity().getFunction()).getProperty());
assertEquals(ExponentialStops.class, layer.getTextOpacity().getFunction().getStops().getClass());
assertEquals(1, ((ExponentialStops) layer.getTextOpacity().getFunction().getStops()).size());
ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops =
(ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getTextOpacity().getFunction().getStops();
Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next();
assertEquals(0f, stop.in.zoom, 0.001);
assertEquals(0.3f, stop.in.value, 0.001f);
assertEquals(0.9f, stop.out, 0.001f);
}
@Test
public void testTextColorAsConstant() {
checkViewIsDisplayed(R.id.mapView);
@@ -1914,6 +2480,77 @@ public class SymbolLayerTest extends BaseStyleTest {
assertEquals(1, ((ExponentialStops) layer.getTextColor().getFunction().getStops()).size());
}
@Test
public void testTextColorAsIdentitySourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("text-color");
assertNotNull(layer);
// Set
layer.setProperties(
textColor(property("FeaturePropertyA", Stops.<String>identity()))
);
// Verify
assertNotNull(layer.getTextColor());
assertNotNull(layer.getTextColor().getFunction());
assertEquals(SourceFunction.class, layer.getTextColor().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextColor().getFunction()).getProperty());
assertEquals(IdentityStops.class, layer.getTextColor().getFunction().getStops().getClass());
}
@Test
public void testTextColorAsExponentialSourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("text-color");
assertNotNull(layer);
// Set
layer.setProperties(
textColor(
property(
"FeaturePropertyA",
exponential(
stop(Color.RED, textColor(Color.RED))
).withBase(0.5f)
)
)
);
// Verify
assertNotNull(layer.getTextColor());
assertNotNull(layer.getTextColor().getFunction());
assertEquals(SourceFunction.class, layer.getTextColor().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextColor().getFunction()).getProperty());
assertEquals(ExponentialStops.class, layer.getTextColor().getFunction().getStops().getClass());
}
@Test
public void testTextColorAsCategoricalSourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("text-color");
assertNotNull(layer);
// Set
layer.setProperties(
textColor(
property(
"FeaturePropertyA",
categorical(
stop("valueA", textColor(Color.RED))
)
)
)
);
// Verify
assertNotNull(layer.getTextColor());
assertNotNull(layer.getTextColor().getFunction());
assertEquals(SourceFunction.class, layer.getTextColor().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextColor().getFunction()).getProperty());
assertEquals(CategoricalStops.class, layer.getTextColor().getFunction().getStops().getClass());
}
@Test
public void testTextColorAsIntConstant() {
checkViewIsDisplayed(R.id.mapView);
@@ -1962,6 +2599,77 @@ public class SymbolLayerTest extends BaseStyleTest {
assertEquals(1, ((ExponentialStops) layer.getTextHaloColor().getFunction().getStops()).size());
}
@Test
public void testTextHaloColorAsIdentitySourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("text-halo-color");
assertNotNull(layer);
// Set
layer.setProperties(
textHaloColor(property("FeaturePropertyA", Stops.<String>identity()))
);
// Verify
assertNotNull(layer.getTextHaloColor());
assertNotNull(layer.getTextHaloColor().getFunction());
assertEquals(SourceFunction.class, layer.getTextHaloColor().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloColor().getFunction()).getProperty());
assertEquals(IdentityStops.class, layer.getTextHaloColor().getFunction().getStops().getClass());
}
@Test
public void testTextHaloColorAsExponentialSourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("text-halo-color");
assertNotNull(layer);
// Set
layer.setProperties(
textHaloColor(
property(
"FeaturePropertyA",
exponential(
stop(Color.RED, textHaloColor(Color.RED))
).withBase(0.5f)
)
)
);
// Verify
assertNotNull(layer.getTextHaloColor());
assertNotNull(layer.getTextHaloColor().getFunction());
assertEquals(SourceFunction.class, layer.getTextHaloColor().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloColor().getFunction()).getProperty());
assertEquals(ExponentialStops.class, layer.getTextHaloColor().getFunction().getStops().getClass());
}
@Test
public void testTextHaloColorAsCategoricalSourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("text-halo-color");
assertNotNull(layer);
// Set
layer.setProperties(
textHaloColor(
property(
"FeaturePropertyA",
categorical(
stop("valueA", textHaloColor(Color.RED))
)
)
)
);
// Verify
assertNotNull(layer.getTextHaloColor());
assertNotNull(layer.getTextHaloColor().getFunction());
assertEquals(SourceFunction.class, layer.getTextHaloColor().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloColor().getFunction()).getProperty());
assertEquals(CategoricalStops.class, layer.getTextHaloColor().getFunction().getStops().getClass());
}
@Test
public void testTextHaloColorAsIntConstant() {
checkViewIsDisplayed(R.id.mapView);
@@ -2010,6 +2718,112 @@ public class SymbolLayerTest extends BaseStyleTest {
assertEquals(1, ((ExponentialStops) layer.getTextHaloWidth().getFunction().getStops()).size());
}
@Test
public void testTextHaloWidthAsIdentitySourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("text-halo-width");
assertNotNull(layer);
// Set
layer.setProperties(
textHaloWidth(property("FeaturePropertyA", Stops.<Float>identity()))
);
// Verify
assertNotNull(layer.getTextHaloWidth());
assertNotNull(layer.getTextHaloWidth().getFunction());
assertEquals(SourceFunction.class, layer.getTextHaloWidth().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloWidth().getFunction()).getProperty());
assertEquals(IdentityStops.class, layer.getTextHaloWidth().getFunction().getStops().getClass());
}
@Test
public void testTextHaloWidthAsExponentialSourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("text-halo-width");
assertNotNull(layer);
// Set
layer.setProperties(
textHaloWidth(
property(
"FeaturePropertyA",
exponential(
stop(0.3f, textHaloWidth(0.3f))
).withBase(0.5f)
)
)
);
// Verify
assertNotNull(layer.getTextHaloWidth());
assertNotNull(layer.getTextHaloWidth().getFunction());
assertEquals(SourceFunction.class, layer.getTextHaloWidth().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloWidth().getFunction()).getProperty());
assertEquals(ExponentialStops.class, layer.getTextHaloWidth().getFunction().getStops().getClass());
}
@Test
public void testTextHaloWidthAsCategoricalSourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("text-halo-width");
assertNotNull(layer);
// Set
layer.setProperties(
textHaloWidth(
property(
"FeaturePropertyA",
categorical(
stop(1.0f, textHaloWidth(0.3f))
)
).withDefaultValue(0.3f)
)
);
// Verify
assertNotNull(layer.getTextHaloWidth());
assertNotNull(layer.getTextHaloWidth().getFunction());
assertEquals(SourceFunction.class, layer.getTextHaloWidth().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloWidth().getFunction()).getProperty());
assertEquals(CategoricalStops.class, layer.getTextHaloWidth().getFunction().getStops().getClass());
assertEquals(0.3f, ((SourceFunction) layer.getTextHaloWidth().getFunction()).getDefaultValue());
}
@Test
public void testTextHaloWidthAsCompositeFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("text-halo-width");
assertNotNull(layer);
// Set
layer.setProperties(
textHaloWidth(
composite(
"FeaturePropertyA",
exponential(
stop(0, 0.3f, textHaloWidth(0.9f))
).withBase(0.5f)
).withDefaultValue(0.3f)
)
);
// Verify
assertNotNull(layer.getTextHaloWidth());
assertNotNull(layer.getTextHaloWidth().getFunction());
assertEquals(CompositeFunction.class, layer.getTextHaloWidth().getFunction().getClass());
assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getTextHaloWidth().getFunction()).getProperty());
assertEquals(ExponentialStops.class, layer.getTextHaloWidth().getFunction().getStops().getClass());
assertEquals(1, ((ExponentialStops) layer.getTextHaloWidth().getFunction().getStops()).size());
ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops =
(ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getTextHaloWidth().getFunction().getStops();
Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next();
assertEquals(0f, stop.in.zoom, 0.001);
assertEquals(0.3f, stop.in.value, 0.001f);
assertEquals(0.9f, stop.out, 0.001f);
}
@Test
public void testTextHaloBlurAsConstant() {
checkViewIsDisplayed(R.id.mapView);
@@ -2047,6 +2861,112 @@ public class SymbolLayerTest extends BaseStyleTest {
assertEquals(1, ((ExponentialStops) layer.getTextHaloBlur().getFunction().getStops()).size());
}
@Test
public void testTextHaloBlurAsIdentitySourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("text-halo-blur");
assertNotNull(layer);
// Set
layer.setProperties(
textHaloBlur(property("FeaturePropertyA", Stops.<Float>identity()))
);
// Verify
assertNotNull(layer.getTextHaloBlur());
assertNotNull(layer.getTextHaloBlur().getFunction());
assertEquals(SourceFunction.class, layer.getTextHaloBlur().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloBlur().getFunction()).getProperty());
assertEquals(IdentityStops.class, layer.getTextHaloBlur().getFunction().getStops().getClass());
}
@Test
public void testTextHaloBlurAsExponentialSourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("text-halo-blur");
assertNotNull(layer);
// Set
layer.setProperties(
textHaloBlur(
property(
"FeaturePropertyA",
exponential(
stop(0.3f, textHaloBlur(0.3f))
).withBase(0.5f)
)
)
);
// Verify
assertNotNull(layer.getTextHaloBlur());
assertNotNull(layer.getTextHaloBlur().getFunction());
assertEquals(SourceFunction.class, layer.getTextHaloBlur().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloBlur().getFunction()).getProperty());
assertEquals(ExponentialStops.class, layer.getTextHaloBlur().getFunction().getStops().getClass());
}
@Test
public void testTextHaloBlurAsCategoricalSourceFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("text-halo-blur");
assertNotNull(layer);
// Set
layer.setProperties(
textHaloBlur(
property(
"FeaturePropertyA",
categorical(
stop(1.0f, textHaloBlur(0.3f))
)
).withDefaultValue(0.3f)
)
);
// Verify
assertNotNull(layer.getTextHaloBlur());
assertNotNull(layer.getTextHaloBlur().getFunction());
assertEquals(SourceFunction.class, layer.getTextHaloBlur().getFunction().getClass());
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloBlur().getFunction()).getProperty());
assertEquals(CategoricalStops.class, layer.getTextHaloBlur().getFunction().getStops().getClass());
assertEquals(0.3f, ((SourceFunction) layer.getTextHaloBlur().getFunction()).getDefaultValue());
}
@Test
public void testTextHaloBlurAsCompositeFunction() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("text-halo-blur");
assertNotNull(layer);
// Set
layer.setProperties(
textHaloBlur(
composite(
"FeaturePropertyA",
exponential(
stop(0, 0.3f, textHaloBlur(0.9f))
).withBase(0.5f)
).withDefaultValue(0.3f)
)
);
// Verify
assertNotNull(layer.getTextHaloBlur());
assertNotNull(layer.getTextHaloBlur().getFunction());
assertEquals(CompositeFunction.class, layer.getTextHaloBlur().getFunction().getClass());
assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getTextHaloBlur().getFunction()).getProperty());
assertEquals(ExponentialStops.class, layer.getTextHaloBlur().getFunction().getStops().getClass());
assertEquals(1, ((ExponentialStops) layer.getTextHaloBlur().getFunction().getStops()).size());
ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops =
(ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getTextHaloBlur().getFunction().getStops();
Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next();
assertEquals(0f, stop.in.zoom, 0.001);
assertEquals(0.3f, stop.in.value, 0.001f);
assertEquals(0.9f, stop.out, 0.001f);
}
@Test
public void testTextTranslateAsConstant() {
checkViewIsDisplayed(R.id.mapView);