com.mapbox.mapboxsdk.style.layers.PropertyValue Java Examples

The following examples show how to use com.mapbox.mapboxsdk.style.layers.PropertyValue. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LocalizationPlugin.java    From mapbox-plugins-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void convertExpression(@NonNull MapLocale mapLocale, Layer layer,
                               PropertyValue<?> textFieldProperty, boolean isStreetsV7) {
  Expression textFieldExpression = textFieldProperty.getExpression();
  if (textFieldExpression != null) {
    MapLocale newMapLocale = mapLocale;
    String mapLanguage = mapLocale.getMapLanguage();
    if (mapLanguage.startsWith("name_zh")) {
      // need to re-get mapLocale, since the default is for street-v8
      newMapLocale = getChineseMapLocale(mapLocale, isStreetsV7);
      Timber.d("reset mapLocale to: %s", newMapLocale.getMapLanguage());
    }

    String text = textFieldExpression.toString().replaceAll(EXPRESSION_REGEX, newMapLocale.getMapLanguage());
    if (text.startsWith("[\"step") && textFieldExpression.toArray().length % 2 == 0) {
      // got an invalid step expression from core, we need to add an additional name_x into step
      text = text.replaceAll(STEP_REGEX, STEP_TEMPLATE);
    }
    layer.setProperties(textField(raw(text)));
  }
}
 
Example #2
Source File: LocalizationPlugin.java    From mapbox-plugins-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void convertExpressionV8(@NonNull MapLocale mapLocale, Layer layer, PropertyValue<?> textFieldProperty) {
  Expression textFieldExpression = textFieldProperty.getExpression();
  if (textFieldExpression != null) {
    String stringExpression =
      textFieldExpression.toString().replaceAll(EXPRESSION_V8_REGEX_LOCALIZED, EXPRESSION_V8_TEMPLATE_BASE);

    String mapLanguage = mapLocale.getMapLanguage();
    if (!mapLanguage.equals(MapLocale.ENGLISH)) {
      if (mapLanguage.equals("name_zh")) {
        mapLanguage = MapLocale.SIMPLIFIED_CHINESE;
      }
      stringExpression = stringExpression.replaceAll(EXPRESSION_V8_REGEX_BASE,
        String.format(Locale.US,
          EXPRESSION_V8_TEMPLATE_LOCALIZED,
          mapLanguage,
          mapLanguage));
    }
    layer.setProperties(textField(raw(stringExpression)));
  }
}
 
Example #3
Source File: AnnotationManager.java    From mapbox-plugins-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void initializeSourcesAndLayers(GeoJsonOptions geoJsonOptions) {
  geoJsonSource = coreElementProvider.getSource(geoJsonOptions);
  layer = coreElementProvider.getLayer();

  style.addSource(geoJsonSource);
  if (belowLayerId == null) {
    style.addLayer(layer);
  } else {
    style.addLayerBelow(layer, belowLayerId);
  }

  initializeDataDrivenPropertyMap();
  layer.setProperties(constantPropertyUsageMap.values().toArray(new PropertyValue[0]));
  if (layerFilter != null) {
    setFilter(layerFilter);
  }

  updateSource();
}
 
Example #4
Source File: AirMapLineLayerStyle.java    From AirMapSDK-Android with Apache License 2.0 5 votes vote down vote up
private PropertyValue getLineColor(PropertyValue pv) {
    if (pv.isExpression()) {
        return PropertyFactory.lineColor(pv.getExpression());
    } else if (pv.isValue()) {
        return PropertyFactory.lineColor(pv.getColorInt());
    }
    return null;
}
 
Example #5
Source File: AirMapSymbolLayerStyle.java    From AirMapSDK-Android with Apache License 2.0 5 votes vote down vote up
private PropertyValue getTextFont(PropertyValue pv) {
    if (pv.isExpression()) {
        return PropertyFactory.textFont(pv.getExpression());
    } else if (pv.isValue()) {
        return PropertyFactory.textFont((String[]) pv.getValue());
    }
    return null;
}
 
Example #6
Source File: AirMapSymbolLayerStyle.java    From AirMapSDK-Android with Apache License 2.0 5 votes vote down vote up
private PropertyValue getTextOffset(PropertyValue pv) {
    if (pv.isExpression()) {
        return PropertyFactory.textOffset(pv.getExpression());
    } else if (pv.isValue()) {
        return PropertyFactory.textOffset((Float[]) pv.getValue());
    }
    return null;
}
 
Example #7
Source File: AirMapFillLayerStyle.java    From AirMapSDK-Android with Apache License 2.0 5 votes vote down vote up
private PropertyValue getFillTranslateAnchor(PropertyValue pv) {
    if (pv.isExpression()) {
        return PropertyFactory.fillTranslateAnchor(pv.getExpression());
    } else if (pv.isValue()) {
        return PropertyFactory.fillTranslateAnchor((String) pv.getValue());
    }
    return null;
}
 
Example #8
Source File: AirMapLineLayerStyle.java    From AirMapSDK-Android with Apache License 2.0 5 votes vote down vote up
private PropertyValue getLineTranslateAnchor(PropertyValue pv) {
    if (pv.isExpression()) {
        return PropertyFactory.lineTranslateAnchor(pv.getExpression());
    } else if (pv.isValue()) {
        return PropertyFactory.lineTranslateAnchor((String) pv.getValue());
    }
    return null;
}
 
Example #9
Source File: AirMapLineLayerStyle.java    From AirMapSDK-Android with Apache License 2.0 5 votes vote down vote up
private PropertyValue getLineTranslate(PropertyValue pv) {
    if (pv.isExpression()) {
        return PropertyFactory.lineTranslate(pv.getExpression());
    } else if (pv.isValue()) {
        return PropertyFactory.lineTranslate((Float[]) pv.getValue());
    }
    return null;
}
 
Example #10
Source File: AirMapLineLayerStyle.java    From AirMapSDK-Android with Apache License 2.0 5 votes vote down vote up
private PropertyValue getLineGapWidth(PropertyValue pv) {
    if (pv.isExpression()) {
        return PropertyFactory.lineGapWidth(pv.getExpression());
    } else if (pv.isValue()) {
        return PropertyFactory.lineGapWidth((Float) pv.getValue());
    }
    return null;
}
 
Example #11
Source File: AirMapLineLayerStyle.java    From AirMapSDK-Android with Apache License 2.0 5 votes vote down vote up
private PropertyValue getLineWidth(PropertyValue pv) {
    if (pv.isExpression()) {
        return PropertyFactory.lineWidth(pv.getExpression());
    } else if (pv.isValue()) {
        return PropertyFactory.lineWidth((Float) pv.getValue());
    }
    return null;
}
 
Example #12
Source File: AirMapLineLayerStyle.java    From AirMapSDK-Android with Apache License 2.0 5 votes vote down vote up
private PropertyValue getLineOpacity(PropertyValue pv) {
    if (pv.isExpression()) {
        return PropertyFactory.lineOpacity(pv.getExpression());
    } else if (pv.isValue()) {
        return PropertyFactory.lineOpacity((Float) pv.getValue());
    }
    return null;
}
 
Example #13
Source File: AirMapSymbolLayerStyle.java    From AirMapSDK-Android with Apache License 2.0 5 votes vote down vote up
private PropertyValue getIconOffset(PropertyValue pv) {
    if (pv.isExpression()) {
        return PropertyFactory.iconOffset(pv.getExpression());
    } else if (pv.isValue()) {
        return PropertyFactory.iconOffset((Float[]) pv.getValue());
    }
    return null;
}
 
Example #14
Source File: AirMapFillLayerStyle.java    From AirMapSDK-Android with Apache License 2.0 5 votes vote down vote up
private PropertyValue getFillPattern(PropertyValue pv) {
    if (pv.isExpression()) {
        return PropertyFactory.fillPattern(pv.getExpression());
    } else if (pv.isValue()) {
        return PropertyFactory.fillPattern((String) pv.getValue());
    }
    return null;
}
 
Example #15
Source File: MapLayerInteractorTest.java    From graphhopper-navigation-android with MIT License 5 votes vote down vote up
@Test
public void updateLayerVisibility_visibilityIsNotSet() {
  SymbolLayer anySymbolOrLineLayer = mock(SymbolLayer.class);
  when(anySymbolOrLineLayer.getSourceLayer()).thenReturn("any");
  List<Layer> layers = buildLayerListWith(anySymbolOrLineLayer);
  MapboxMap map = mock(MapboxMap.class);
  when(map.getLayers()).thenReturn(layers);
  MapLayerInteractor layerInteractor = new MapLayerInteractor(map);

  layerInteractor.updateLayerVisibility(true, "random");

  verify(anySymbolOrLineLayer, times(0)).setProperties(any(PropertyValue.class));
}
 
Example #16
Source File: AirMapFillLayerStyle.java    From AirMapSDK-Android with Apache License 2.0 5 votes vote down vote up
private PropertyValue getFillColor(PropertyValue pv) {
    if (pv.isExpression()) {
        return PropertyFactory.fillColor(pv.getExpression());
    } else if (pv.isValue()) {
        return PropertyFactory.fillColor(pv.getColorInt());
    }
    return null;
}
 
Example #17
Source File: AirMapLineLayerStyle.java    From AirMapSDK-Android with Apache License 2.0 5 votes vote down vote up
private PropertyValue getLineDashArray(PropertyValue pv) {
    if (pv.isExpression()) {
        return PropertyFactory.lineDasharray(pv.getExpression());
    } else if (pv.isValue()) {
        return PropertyFactory.lineDasharray((Float[]) pv.getValue());
    }
    return null;
}
 
Example #18
Source File: AirMapSymbolLayerStyle.java    From AirMapSDK-Android with Apache License 2.0 5 votes vote down vote up
private PropertyValue getTextField(PropertyValue pv) {
    if (pv.isExpression()) {
        return PropertyFactory.textField(pv.getExpression());
    } else if (pv.isValue()) {
        return PropertyFactory.textField((String) pv.getValue());
    }
    return null;
}
 
Example #19
Source File: AirMapSymbolLayerStyle.java    From AirMapSDK-Android with Apache License 2.0 5 votes vote down vote up
private PropertyValue getTextOpacity(PropertyValue pv) {
    if (pv.isExpression()) {
        return PropertyFactory.textOpacity(pv.getExpression());
    } else if (pv.isValue()) {
        return PropertyFactory.textOpacity((Float) pv.getValue());
    }
    return null;
}
 
Example #20
Source File: AirMapSymbolLayerStyle.java    From AirMapSDK-Android with Apache License 2.0 5 votes vote down vote up
private PropertyValue getIconOpacity(PropertyValue pv) {
    if (pv.isExpression()) {
        return PropertyFactory.iconOpacity(pv.getExpression());
    } else if (pv.isValue()) {
        return PropertyFactory.iconOpacity((Float) pv.getValue());
    }
    return null;
}
 
Example #21
Source File: AirMapSymbolLayerStyle.java    From AirMapSDK-Android with Apache License 2.0 5 votes vote down vote up
private PropertyValue getIconSize(PropertyValue pv) {
    if (pv.isExpression()) {
        return PropertyFactory.iconSize(pv.getExpression());
    } else if (pv.isValue()) {
        return PropertyFactory.iconSize((Float) pv.getValue());
    }
    return null;
}
 
Example #22
Source File: AirMapSymbolLayerStyle.java    From AirMapSDK-Android with Apache License 2.0 5 votes vote down vote up
private PropertyValue getIconPadding(PropertyValue pv) {
    if (pv.isExpression()) {
        return PropertyFactory.iconPadding(pv.getExpression());
    } else if (pv.isValue()) {
        return PropertyFactory.iconPadding((Float) pv.getValue());
    }
    return null;
}
 
Example #23
Source File: AirMapSymbolLayerStyle.java    From AirMapSDK-Android with Apache License 2.0 5 votes vote down vote up
private PropertyValue getAvoidEdges(PropertyValue pv) {
    if (pv.isExpression()) {
        return PropertyFactory.symbolAvoidEdges(pv.getExpression());
    } else if (pv.isValue()) {
        return PropertyFactory.symbolAvoidEdges((Boolean) pv.getValue());
    }
    return null;
}
 
Example #24
Source File: AirMapSymbolLayerStyle.java    From AirMapSDK-Android with Apache License 2.0 5 votes vote down vote up
private PropertyValue getIconImage(PropertyValue pv) {
    if (pv.isExpression()) {
        return PropertyFactory.iconImage(pv.getExpression());
    } else if (pv.isValue()) {
        return PropertyFactory.iconImage((String) pv.getValue());
    }
    return null;
}
 
Example #25
Source File: AirMapSymbolLayerStyle.java    From AirMapSDK-Android with Apache License 2.0 5 votes vote down vote up
private PropertyValue getIconKeepUpright(PropertyValue pv) {
    if (pv.isExpression()) {
        return PropertyFactory.iconKeepUpright(pv.getExpression());
    } else if (pv.isValue()) {
        return PropertyFactory.iconKeepUpright((Boolean) pv.getValue());
    }
    return null;
}
 
Example #26
Source File: AirMapSymbolLayerStyle.java    From AirMapSDK-Android with Apache License 2.0 5 votes vote down vote up
private PropertyValue getIconAllowOverlap(PropertyValue pv) {
    if (pv.isExpression()) {
        return PropertyFactory.iconAllowOverlap(pv.getExpression());
    } else if (pv.isValue()) {
        return PropertyFactory.iconAllowOverlap((Boolean) pv.getValue());
    }
    return null;
}
 
Example #27
Source File: AirMapSymbolLayerStyle.java    From AirMapSDK-Android with Apache License 2.0 5 votes vote down vote up
private PropertyValue getSymbolSpacing(PropertyValue pv) {
    if (pv.isExpression()) {
        return PropertyFactory.symbolSpacing(pv.getExpression());
    } else if (pv.isValue()) {
        return PropertyFactory.symbolSpacing((Float) pv.getValue());
    }
    return null;
}
 
Example #28
Source File: AirMapSymbolLayerStyle.java    From AirMapSDK-Android with Apache License 2.0 5 votes vote down vote up
private PropertyValue getSymbolPlacement(PropertyValue pv) {
    if (pv.isExpression()) {
        return PropertyFactory.symbolPlacement(pv.getExpression());
    } else if (pv.isValue()) {
        return PropertyFactory.symbolPlacement((String) pv.getValue());
    }
    return null;
}
 
Example #29
Source File: PropertyValueMatcher.java    From mapbox-plugins-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public boolean matches(PropertyValue argument) {
  if (argument == wanted) {
    return true;
  } else if (!argument.name.equals(wanted.name)) {
    return false;
  } else if (argument.getValue() != null && wanted.getValue() != null) {
    return argument.getValue().equals(wanted.getValue());
  } else if (argument.getExpression() != null && wanted.getExpression() != null) {
    return Arrays.deepEquals(argument.getExpression().toArray(), wanted.getExpression().toArray());
  } else {
    return argument.getValue() == null && wanted.getValue() == null
      && argument.getExpression() == null && wanted.getExpression() == null;
  }
}
 
Example #30
Source File: AirMapLineLayerStyle.java    From AirMapSDK-Android with Apache License 2.0 5 votes vote down vote up
private PropertyValue getLinePattern(PropertyValue pv) {
    if (pv.isExpression()) {
        return PropertyFactory.linePattern(pv.getExpression());
    } else if (pv.isValue()) {
        return PropertyFactory.linePattern((String) pv.getValue());
    }
    return null;
}