Exemplo n.º 1
0
std::string JsonUtils::MapLayerJson(const MapLayerJSConfig::Layer& layer,
                                    const DbHeader& db_header,
                                    const std::string& locale) {
  // Get the legend for the specified locale.
  const LegendLocale& legend_locale = layer.legend_.GetLegendLocale(locale);
  // Create the map of field name-value pairs for the output JSON.
  std::string icon_name =
      "icons/" + legend_locale.icon.GetValue().LegendHref();
  bool is_imagery = (layer.type_ == MapLayerJSConfig::Layer::Imagery);
  double opacity = 1.0;
  std::map<std::string, std::string> field_map;
  field_map["id"] = Itoa(layer.channel_id_);
  field_map["version"] = Itoa(layer.index_version_);
  field_map["label"] = Quoted(legend_locale.name.GetValue());
  field_map["icon"] = Quoted(icon_name);
  field_map["initialState"] =
    JsonUtils::JsonBool(legend_locale.isChecked.GetValue());
  field_map["isPng"] = JsonUtils::JsonBool(!is_imagery);
  field_map["opacity"] = DoubleToString(opacity);

  field_map["requestType"] = Quoted(
      MapLayerRequestType(db_header.is_mercator_, layer));

  // TODO: add new locale fields
  // opacity (needs locale entry and ui)
  // look_at (needs ui)
  std::string lookAt(legend_locale.lookAt.GetValue().utf8());
  field_map["lookAt"] = JsonUtils::LookAtJson(lookAt);
  return JsonObject(field_map);
}
Exemplo n.º 2
0
std::string JsonUtils::SearchTabJson(const SearchTabDefinition& search_tab) {
  // The JSON publishes the MapsSearchAdapter for all search url's, since the
  // JS processing code is the same for all JSON based clients.
  std::string url = search_tab.url.utf8().data();
  url = ReplaceString(url, kEarthClientSearchAdapter, kMapsSearchAdapter);

  // Collect the arg fields into a vector.
  std::vector<std::string> arg_array_entries;
  for (int i = 0; i < static_cast<int>(search_tab.fields.size()); ++i) {
    const SearchTabDefinition::Field& field = search_tab.fields[i];
    std::map<std::string, std::string> arg_field_map;
    arg_field_map["screenLabel"] = Quoted(field.label);
    arg_field_map["urlTerm"] = Quoted(field.key);

    std::string arg_entry = JsonObject(arg_field_map);
    arg_array_entries.push_back(arg_entry);
  }
  std::string args_array = JsonArray(arg_array_entries);

  // Create the map of field name-value pairs for the output JSON.
  std::map<std::string, std::string> field_map;
  field_map["tabLabel"] = Quoted(search_tab.label);
  field_map["url"] = Quoted(url);
  field_map["args"] = args_array;
  return JsonObject(field_map);
}
Exemplo n.º 3
0
std::string JsonUtils::GELayerJson(const LayerConfig& layer,
                                   const std::string& locale) {
  LocaleConfig locale_config = layer.GetLocale(locale);

  // Create the map of field name-value pairs for the output JSON.
  std::map<std::string, std::string> field_map;
  field_map["id"] = Quoted(layer.asset_uuid_);
  field_map["label"] = Quoted(locale_config.name_.GetValue());
  field_map["description"] = Quoted(locale_config.desc_.GetValue());
  field_map["isInitiallyOn"] =
    JsonUtils::JsonBool(locale_config.is_checked_.GetValue());
  field_map["isExpandable"] = JsonUtils::JsonBool(layer.isExpandable);
  field_map["isEnabled"] = JsonUtils::JsonBool(layer.isEnabled);
  field_map["isVisible"] = JsonUtils::JsonBool(layer.isVisible);
  std::string lookAt(locale_config.look_at_.GetValue().utf8());
  field_map["lookAt"] = JsonUtils::LookAtJson(lookAt);
  return JsonObject(field_map);
}
Exemplo n.º 4
0
std::string JsonUtils::GERasterLayerJson(
  const RasterDBRootGenConfig::Layer& layer,
  const std::string& locale) {
  LegendLocale locale_config = layer.legend_.GetLegendLocale(locale);

  // Create the map of field name-value pairs for the output JSON.
  std::map<std::string, std::string> field_map;
  field_map["id"] = Quoted(layer.asset_uuid_);
  field_map["label"] = Quoted(locale_config.name.GetValue());
  field_map["description"] = Quoted(locale_config.desc.GetValue());
  field_map["isInitiallyOn"] =
    JsonUtils::JsonBool(locale_config.isChecked.GetValue());
  field_map["isExpandable"] = JsonUtils::JsonBool(false);
  field_map["isEnabled"] = JsonUtils::JsonBool(true);
  field_map["isVisible"] = JsonUtils::JsonBool(true);
  std::string lookAt(locale_config.lookAt.GetValue().utf8());
  field_map["lookAt"] = JsonUtils::LookAtJson(lookAt);
  return JsonObject(field_map);
}
Exemplo n.º 5
0
std::string JsonUtils::GEJsonBuffer(
  const std::string& database_url,
  const std::string& host_domain,
  const std::string& protocol,
  const std::vector<RasterDBRootGenConfig::Layer>& raster_layers,
  const std::vector<LayerConfig>& vector_layers,
  const std::string& locale) {
  std::string layers_json =
      JsonUtils::GELayersJson(raster_layers, vector_layers, locale);

  // Create the map of field name-value pairs for the output JSON.
  std::map<std::string, std::string> field_map;
  field_map["dbType"] = Quoted(std::string("gedb"));
  field_map["serverUrl"] = Quoted(database_url);
  field_map["isAuthenticated"] =
      JsonUtils::JsonBool(protocol.compare("https") == 0);
  field_map["layers"] = layers_json;
  return JsonObject(field_map);
}
Exemplo n.º 6
0
std::string JsonUtils::MapsJsonBuffer(
  const std::string& database_url,
  const std::string& host_domain,
  const std::string& protocol,
  const std::vector<MapLayerJSConfig::Layer>& layers,
  const DbHeader& db_header,
  const std::string& locale) {
  std::string layers_json = JsonUtils::MapLayersJson(layers, db_header, locale);

  // Create the map of field name-value pairs for the output JSON.
  std::map<std::string, std::string> field_map;
  field_map["dbType"] = Quoted(std::string("gemap"));
  field_map["serverUrl"] = Quoted(database_url);
  field_map["useGoogleLayers"] =
      JsonUtils::JsonBool(db_header.use_google_imagery_);
  field_map["isAuthenticated"] =
      JsonUtils::JsonBool(database_url.find("https") == 0);
  field_map["projection"] =
      Quoted(std::string(db_header.is_mercator_ ? "mercator" : "flat"));
  field_map["layers"] = layers_json;
  return JsonObject(field_map);
}
Exemplo n.º 7
0
std::string JsonUtils::LookAtJson(const std::string& lookAtSpec) {
  if (lookAtSpec.empty())
    return Quoted(std::string("none"));
  // LookAtSpec format is :
  // longitude|latitude|altitude|...
  // we only care for these 3.
  std::vector<std::string> tokens;
  TokenizeString(lookAtSpec, tokens, "|");

  double altitude = strtod(tokens[2].c_str(), NULL);
  int zoomLevel = AltitudeToZoomLevel(altitude);

  // Create the map of field name-value pairs for the output JSON.
  std::map<std::string, std::string> field_map;
  field_map["lat"] = tokens[1];
  field_map["lng"] = tokens[0];
  field_map["zoom"] = Itoa(zoomLevel);
  field_map["altitude"] = DoubleToString(altitude);
  return JsonObject(field_map);
}
Exemplo n.º 8
0
/**
 * @return this, because we never interpret it.
 * @param environment Not used. 
 */
Element Quoted_::Interpret_(Environment& /* environment */)
{
    return Quoted(shared_from_this(), SourceLocation());
}