ย้ายข้อมูลไปยัง Solar API บน Google Maps Platform

หากต้องการย้ายจาก Google Earth Engine Solar API ไปยัง Google Maps Platform Solar API ให้ทำดังนี้

  1. เปิดใช้ Solar API ของ Google Maps Platform ในโปรเจ็กต์ที่อยู่ในระบบคลาวด์
  2. สร้างคีย์ใหม่และจำกัดคีย์ดังกล่าวให้ใช้กับ GMP Solar API เท่านั้น
  3. อัปเดตโค้ดโดยทำตามวิธีการทีละขั้นตอนด้านล่าง

การเปรียบเทียบข้อมูลคู่กัน

Solar API (ใหม่) บ้านที่มีดวงอาทิตย์ Earth Engine Solar API (เลิกใช้งานแล้ว) ไอคอน EE
สถานะการเปิดใช้งาน เปิดตัวแล้ว นำร่อง (เลิกใช้งานแล้ว)
การเข้าถึง
กลไก บัญชี Google Cloud ผ่าน Cloud Console โดยการเปิดใช้ Solar API และจัดการ API ผ่านส่วน Google Maps Platform บัญชี Google Cloud ผ่าน Cloud Console โดยการเปิดใช้ Earth Engine Solar API
ใคร สาธารณะ ควบคุมการเข้าถึง
ระดับ จัดสรรเอง สิทธิ์เข้าถึงโปรเจ็กต์ที่อยู่ในระบบคลาวด์ด้วยตนเอง
การตรวจสอบสิทธิ์ คีย์ API และ OAuth คีย์ API
การกำหนดราคา
การพากย์เสียง Pay-as-you-go ส่วนลด 100%
การแบ่งระดับ ต่อการค้นหา 1, 000 ครั้งโดยลดราคาลงตามปริมาณ
ปลายทาง ราคาของแต่ละปลายทางต่างกัน
Cloud
Monitoring Cloud Monitoring ใน "Google Maps Platform" Cloud Monitoring ในส่วน "API และบริการ"
โควต้า QPM (จำนวนคำค้นหาต่อนาที) และ QPH (จำนวนคำค้นหาต่อชั่วโมง) รายปี
Logging Cloud Logging (ไม่บังคับ) Cloud Logging (ไม่บังคับ)
การเรียกเก็บเงิน บัญชีสำหรับการเรียกเก็บเงินใน Cloud -
การสนับสนุน การรองรับ Google Maps Platform เต็มรูปแบบพร้อม SLO/SLA จำกัด, ทางอีเมล
API
ชื่อโฮสต์ https://solar.googleapis.com/v1/ (พัก) https://earthenginesolar.googleapis.com/v1/ (พัก)
วิธีการ
  • 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 ได้ หากสร้างโปรเจ็กต์ไม่ได้ โปรดติดต่อผู้ดูแลระบบขององค์กร

หรือจะใช้โปรเจ็กต์ที่อยู่ในระบบคลาวด์ที่มีอยู่แล้วก็ได้ ดูข้อมูลเพิ่มเติมได้ที่การเริ่มต้นใช้งาน Google Maps Platform

ตั้งค่าบัญชีสำหรับการเรียกเก็บเงิน

โปรดดูวิธีการที่ วิธีจัดการบัญชีสำหรับการเรียกเก็บเงิน

คุณใช้โปรเจ็กต์ Cloud ที่มีอยู่กับบัญชีสำหรับการเรียกเก็บเงินที่มีอยู่ได้

รับคีย์ API หรือใช้โทเค็น OAuth

หลังจากตั้งค่าโปรเจ็กต์ Google Cloud แล้ว คุณต้องสร้างและรักษาความปลอดภัยคีย์ API เพื่อใช้ Solar API ตามที่อธิบายไว้ในใช้คีย์ API หรือจะสร้างโทเค็น OAuth ตามที่อธิบายไว้ในหัวข้อใช้ OAuth ก็ได้

ใช้ Solar API

  • สร้างคำขอ GET ไปยังปลายทางใหม่ : https://solar.googleapis.com
  • โปรดทราบว่าชื่อเมธอด API บางชื่อได้มีการเปลี่ยนแปลง ดังนี้
    • buildings:findClosestbuildingInsights:findClosest
    • solarinfo:getdataLayers:get

การทดลองใช้ด่วน: ใช้คีย์ API ที่บันทึกไว้จากขั้นตอนก่อนหน้าและแทนที่ YOUR_API_KEY ในการค้นหาตัวอย่างด้านล่างก่อนที่จะโหลด URL ในเบราว์เซอร์

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

การตอบกลับสำหรับรุ่นตัวอย่างต้นฉบับ

สำหรับรุ่นตัวอย่างเดิมในวันที่ 9 พฤษภาคม 2023 นั้น URL ในการตอบกลับจะอยู่ในรูปแบบดังนี้

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",
    ...
  ]
  }

หากต้องการส่งคำขอไปยัง URL ในการตอบกลับ ให้ใส่ทั้ง URL ในคำขอ

ดูข้อกำหนดทั้งหมดของคำขอและคำตอบนี้ได้ในเอกสารอ้างอิง

เขียนแอปเพื่อให้รองรับคำตอบทั้ง 2 รูปแบบ

ตอนนี้คุณเขียนแอปที่จัดการทั้งตัวอย่างรูปแบบเดิมและรูปแบบคำตอบปัจจุบันได้แล้ว

ความแตกต่างที่สำคัญระหว่างการตอบกลับ 2 รายการ (นอกเหนือจาก URL จริง) คือคุณต้องส่งคีย์ API ไปยังคำขอที่เข้าถึง URL จากรูปแบบการตอบกลับใหม่ หากคุณไม่ใส่คีย์ API คำขอจะไม่สำเร็จ

เช่น คุณเพิ่มโค้ดต่อไปนี้ลงในแอปเพื่อตรวจสอบ URL และจัดการแต่ละเวอร์ชันได้อย่างถูกต้อง

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

เคล็ดลับน่ารู้

  • โควต้า: การใช้งานที่สามารถปรับขนาดได้ (แทนที่จะเป็นรายปีซึ่งจะหายไป)
    • โควต้าปัจจุบัน ซึ่งจะเปลี่ยนเป็น QPM
    • แนวทางปฏิบัติแนะนำ: กำหนดโควต้าฝั่งไคลเอ็นต์และส่งการแจ้งเตือน
  • ราคา:
    • Pay-as-you-go
    • คำตอบ 404 NOT_FOUND หากตำแหน่งไม่ได้อยู่ในช่วงการครอบคลุม จะไม่ถูกเรียกเก็บเงินแต่จะนับรวมในโควต้า
  • ข้อกำหนดการใช้งานทั่วไป: ข้อกำหนดในการให้บริการของ Google Maps Platform