迁移到 Google Maps Platform 上的 Solar API

从 Google Earth Engine Solar API 迁移到 Google Maps Platform Solar API:

  1. 在您的云项目中启用 Google Maps Platform Solar API。
  2. 创建一个新密钥并将其限制为仅限 GMP Solar API。
  3. 使用 分步说明 具体说明。

并列比较

Solar API(新)有阳光的房子 Earth Engine Solar API(已弃用)EE 图标
发布状态 已发布 试用(已弃用)
访问
机制 通过 Cloud 控制台启用 Solar API,并通过 Google Maps Platform 部分管理该 API,从而通过 Cloud 控制台管理 Google Cloud 账号 通过 Cloud 控制台启用 Earth Engine Solar API 即可访问 Google Cloud 账号
参与者 公开 已控制访问权限
级别 自行配置 Cloud 项目手动访问
身份验证 API 密钥和 OAuth API 密钥
价格
策略 随用随付 100%折扣
分级 每 1000 次查询,价格随查询量而降低
端点 每个端点的价格有所不同
Cloud
监控 “Google Maps Platform”下的 Cloud Monitoring Cloud Monitoring(位于“API 和服务”下)
配额 QPM(每分钟查询次数)和 QPH(每小时查询次数) 包年
日志记录 Cloud Logging(可选) Cloud Logging(可选)
结算 Cloud Billing 账号 -
支持 具有 SLO/SLA 的 Google Maps Platform 全面支持 受限(通过电子邮件)
API
主机名 https://solar.googleapis.com/v1/ (REST) https://earthenginesolar.googleapis.com/v1/ (REST)
方法
  • buildingInsights:findClosest
  • dataLayers:get
  • buildings:findClosest
  • solar.get
响应 与小规模测试相比没有变化
solarInfo 半径不超过 100 米 半径不超过 100 米
覆盖率
全球 全球
数据质量 HIGH/MEDIUM HIGH/MEDIUM
建筑物类型 映射到某个地址的任何建筑物,且位于 Solar API 图像覆盖范围之内 映射到某个地址的任何建筑物,且位于 Solar API 图像覆盖范围之内
服务条款
TOS Google Maps Platform 条款 Google Earth Engine 条款

分步说明

设置您的 Google Cloud 项目

此处的说明:设置您的 Google Cloud 项目

只有特定角色可以 创建 Cloud 项目;如果您无法创建项目,请联系您的 组织管理员。

您也可以使用现有的 Cloud 项目。如需了解详情,请参阅入门指南 使用 Google Maps Platform

设置结算账号

点击此处查看说明:如何管理您的结算 账号

您可以使用已有结算账号的现有 Cloud 项目。

获取 API 密钥或使用 OAuth 令牌

设置 Google Cloud 项目后,您必须创建并保护您的 API 使用 Solar API 的密钥(如使用 API 中所述) 键。您也可以创建一个 OAuth 令牌 (具体说明请参阅使用 OAuth)。

使用 Solar API

  • 向新端点发出 GET 请求:https://solar.googleapis.com
  • 请注意,某些 API 方法名称已更改: <ph type="x-smartling-placeholder">
      </ph>
    • buildings:findClosestbuildingInsights:findClosest
    • solarinfo:getdataLayers:get

快速试用:使用上一步中保存的 API 密钥,并替换 YOUR_API_KEY,然后再在 浏览器:

https://solar.googleapis.com/v1/dataLayers:get?location.latitude=37.2746464&location.longitude=-121.7530949&radius_meters=10&key=YOUR_API_KEY

原始预览版的响应

对于 2023 年 5 月 9 日的原始预览版,响应中的网址如下: 表单:

https://earthengine.googleapis.com/v1alpha/projects/sunroof-api/thumbnails/THUMBNAIL_ID:getPixels

以下代码段是一个示例响应:

{
  "imageryDate": {
    "year": 2015,
    "month": 8,
    "day": 8
  },
  "imageryProcessedDate": {
    "year": 2021,
    "month": 2,
    "day": 15
  },
  "dsmUrl": "https://earthengine.googleapis.com/v1alpha/projects/geo-solar-api/thumbnails/fbde33e9cd16d5fd10d19a19dc580bc1-8614f599c5c264553f821cd034d5cf32:getPixels",
  "rgbUrl": "https://earthengine.googleapis.com/v1alpha/projects/geo-solar-api/thumbnails/91ed3551f2d0abee20af35e07bd0c927-c96c59e80cf1fc1dc86cf59fc8ec86ba:getPixels",
  "maskUrl": "https://earthengine.googleapis.com/v1alpha/projects/geo-solar-api/thumbnails/e4051553dba6870c03d855ae82c30b7e-7cc8ae6ce7c73f219e3c1924e5c17fc6:getPixels",
  "annualFluxUrl": "https://earthengine.googleapis.com/v1alpha/projects/geo-solar-api/thumbnails/9b0f87f49d778a65c9e27ff936e6dbba-b90be2fe80d25abd4c9e8c4dc809f763:getPixels",
  "monthlyFluxUrl": "https://earthengine.googleapis.com/v1alpha/projects/geo-solar-api/thumbnails/90e7cca77402f14809e349937f0a0be8-94fafeb4ef42d72f1b3c0652a1cb5518:getPixels",
  "hourlyShadeUrls": [
    "https://earthengine.googleapis.com/v1alpha/projects/geo-solar-api/thumbnails/dcd276e4782aef4ff1b230b781736d37-e193b231ce57a03449afc3e21cf6783b:getPixels",
    ...
  ]
  }

要在响应中向某个网址发出请求,请在 请求。

有关此请求和响应的完整规范,请参阅参考 文档

编写支持这两种响应格式的应用

现在,您可以编写一个可同时处理原始预览和当前预览的应用 响应格式。

除了实际网址本身以外,两种响应之间的主要区别是: 您必须将 API 密钥传递给从 new 响应格式。如果您省略 API 密钥,请求将失败。

例如,您可以将以下代码添加到应用中,以检查网址和 正确处理每个版本:

JavaScript

/**
* Function to examine a response URL and to append the API key to the
* URL if it is in the new format.
*/
function prepareGetGeoTiffUrl(geoTiffUrl, apiKey) {
  if (geoTiffUrl.match("solar.googleapis.com")) {
    let url = new URL(geoTiffUrl);
    url.searchParams.set('apiKey', apiKey);
    return url.toString();
  }
  return geoTiffUrl;
}

Python

# Functions to examine a response URL and to append the API key to the
# URL if it is in the new format.

def add_api_key_to_url(base_url: str, api_key: str) -> str:
  '''Formats URL that currently lacks an API key to use the one provided.'''
  return base_url + "&key=" +api_key;

def prepare_geo_tiff_url(base_url: str, api_key: str) -> str:
  '''Prepares URL from GetDataLayers depending on API being called.
    If the geoTIFF url from GetDataLayers is for the solar API GetGeoTiff
      endpoint, append the API key. Otherwise return the URL as is.
  '''
  if re.search("solar.googleapis.com", geo_tiff_url):
    return add_api_key_to_url(geo_tiff_url, api_key)
  return geo_tiff_url

Java

/ **Adds API key to a URL. /*
private String addApiKeyToUrl(String geoTiffUrl, String apiKey) {
  return geoTiffUrl + "&key=" + apiKey;
}

/
** *Function to examine a response URL and to append the API key to the
 *URL if it is in the new format.
/*
private String prepareGetGeoTiffUrl(String geoTiffUrl, String apiKey) {
  Pattern pattern = Pattern.compile("solar.googleapis.com");
  Matcher matcher = pattern.matcher(geoTiffUrl);
  if (matcher.find()) {
    return addApiKeyToUrl(geoTiffUrl, apiKey);
  } else {
    return geoTiffUrl;
  }
}

监控

项目级 结算账号级别

Cloud Monitoring Cloud Billing

实用提示

  • 配额:可以扩缩的用量(而不是按年计费,这样会消失) <ph type="x-smartling-placeholder">
      </ph>
    • 当前 配额 该级别将更改为 QPM
    • 最佳实践:设置客户端配额并发送提醒
  • 价格: <ph type="x-smartling-placeholder">
      </ph>
    • 随用随付
    • 当位置不在信号覆盖范围内时,404 NOT_FOUND 响应将 不会计费,但会计入配额
  • 通用条款:Google Maps Platform 服务条款