Membuat permintaan insight build

Endpoint buildingInsights memberikan insight tentang lokasi, dimensi, dan potensi tenaga surya dari suatu bangunan. Secara khusus, Anda bisa mendapatkan informasi tentang:

  • Potensi tenaga surya, termasuk ukuran panel surya, jumlah sinar matahari tahunan, faktor kompensasi karbon, dan lainnya
  • Posisi, orientasi, dan produksi energi panel surya
  • Perkiraan tagihan energi bulanan untuk tata letak panel surya yang optimal serta biaya dan manfaat terkait

Untuk mempelajari lebih lanjut cara Solar API mendefinisikan potensi dan daya surya, lihat Konsep Solar API.

API Explorer memungkinkan Anda membuat permintaan langsung sehingga Anda dapat memahami opsi API dan API:

Cobalah!

Tentang membuat permintaan insight

Untuk meminta insight pembuatan, kirim permintaan GET HTTP ke:

https://solar.googleapis.com/v1/buildingInsights:findClosest?key=YOUR_API_KEY

Sertakan parameter URL permintaan Anda yang menentukan koordinat lintang dan bujur lokasi serta tingkat kualitas minimum yang diperlukan yang diizinkan dalam hasil.

Contoh permintaan insight bangunan

Contoh berikut meminta informasi insight bangunan untuk lokasi pada koordinat lintang = 37,4450 dan bujur = -122,1390:

Kunci API

Untuk membuat permintaan ke URL dalam respons, tambahkan kunci API Anda ke URL:

curl -X GET "https://solar.googleapis.com/v1/buildingInsights:findClosest?location.latitude=37.4450&location.longitude=-122.1390&requiredQuality=HIGH&key=YOUR_API_KEY"

Anda juga dapat membuat permintaan HTTP dengan menempelkan URL di permintaan cURL ke kolom URL browser Anda. Meneruskan kunci API akan memberi Anda kemampuan penggunaan dan analisis yang lebih baik serta kontrol akses yang lebih baik ke data respons.

Token OAuth

Catatan: Format ini hanya untuk lingkungan pengujian. Untuk informasi lebih lanjut, lihat Menggunakan OAuth.

Untuk membuat permintaan ke URL dalam respons, teruskan nama project penagihan dan token OAuth Anda:

curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  -H "X-Goog-User-Project: PROJECT_NUMBER_OR_ID" \
  "https://solar.googleapis.com/v1/buildingInsights:findClosest?location.latitude=37.4450&location.longitude=-122.1390"
        

TypeScript

Untuk membuat permintaan ke URL dalam respons, sertakan kunci API atau token OAuth Anda dalam permintaan. Berikut adalah contoh yang menggunakan kunci API:

/**
 * Fetches the building insights information from the Solar API.
 *   https://developers.google.com/maps/documentation/solar/building-insights
 *
 * @param  {LatLng} location      Point of interest as latitude longitude.
 * @param  {string} apiKey        Google Cloud API key.
 * @return {Promise<DataLayersResponse>}  Building Insights response.
 */
export async function findClosestBuilding(
  location: google.maps.LatLng,
  apiKey: string,
): Promise<BuildingInsightsResponse> {
  const args = {
    'location.latitude': location.lat().toFixed(5),
    'location.longitude': location.lng().toFixed(5),
  };
  console.log('GET buildingInsights\n', args);
  const params = new URLSearchParams({ ...args, key: apiKey });
  // https://developers.google.com/maps/documentation/solar/reference/rest/v1/buildingInsights/findClosest
  return fetch(`https://solar.googleapis.com/v1/buildingInsights:findClosest?${params}`).then(
    async (response) => {
      const content = await response.json();
      if (response.status != 200) {
        console.error('findClosestBuilding\n', content);
        throw content;
      }
      console.log('buildingInsightsResponse', content);
      return content;
    },
  );
}

Definisi tipe data

Jenis data berikut ini didukung:

export interface DataLayersResponse {
  imageryDate: Date;
  imageryProcessedDate: Date;
  dsmUrl: string;
  rgbUrl: string;
  maskUrl: string;
  annualFluxUrl: string;
  monthlyFluxUrl: string;
  hourlyShadeUrls: string[];
  imageryQuality: 'HIGH' | 'MEDIUM' | 'LOW';
}

export interface Bounds {
  north: number;
  south: number;
  east: number;
  west: number;
}

// https://developers.google.com/maps/documentation/solar/reference/rest/v1/buildingInsights/findClosest
export interface BuildingInsightsResponse {
  name: string;
  center: LatLng;
  boundingBox: LatLngBox;
  imageryDate: Date;
  imageryProcessedDate: Date;
  postalCode: string;
  administrativeArea: string;
  statisticalArea: string;
  regionCode: string;
  solarPotential: SolarPotential;
  imageryQuality: 'HIGH' | 'MEDIUM' | 'LOW';
}

export interface SolarPotential {
  maxArrayPanelsCount: number;
  panelCapacityWatts: number;
  panelHeightMeters: number;
  panelWidthMeters: number;
  panelLifetimeYears: number;
  maxArrayAreaMeters2: number;
  maxSunshineHoursPerYear: number;
  carbonOffsetFactorKgPerMwh: number;
  wholeRoofStats: SizeAndSunshineStats;
  buildingStats: SizeAndSunshineStats;
  roofSegmentStats: RoofSegmentSizeAndSunshineStats[];
  solarPanels: SolarPanel[];
  solarPanelConfigs: SolarPanelConfig[];
  financialAnalyses: object;
}

export interface SizeAndSunshineStats {
  areaMeters2: number;
  sunshineQuantiles: number[];
  groundAreaMeters2: number;
}

export interface RoofSegmentSizeAndSunshineStats {
  pitchDegrees: number;
  azimuthDegrees: number;
  stats: SizeAndSunshineStats;
  center: LatLng;
  boundingBox: LatLngBox;
  planeHeightAtCenterMeters: number;
}

export interface SolarPanel {
  center: LatLng;
  orientation: 'LANDSCAPE' | 'PORTRAIT';
  segmentIndex: number;
  yearlyEnergyDcKwh: number;
}

export interface SolarPanelConfig {
  panelsCount: number;
  yearlyEnergyDcKwh: number;
  roofSegmentSummaries: RoofSegmentSummary[];
}

export interface RoofSegmentSummary {
  pitchDegrees: number;
  azimuthDegrees: number;
  panelsCount: number;
  yearlyEnergyDcKwh: number;
  segmentIndex: number;
}

export interface LatLng {
  latitude: number;
  longitude: number;
}

export interface LatLngBox {
  sw: LatLng;
  ne: LatLng;
}

export interface Date {
  year: number;
  month: number;
  day: number;
}

export interface RequestError {
  error: {
    code: number;
    message: string;
    status: string;
  };
}

Contoh objek respons

Permintaan tersebut menghasilkan respons JSON dalam bentuk:

{
  "name": "buildings/ChIJh0CMPQW7j4ARLrRiVvmg6Vs",
  "center": {
    "latitude": 37.4449439,
    "longitude": -122.13911639999999
  },
  "imageryDate": {
    "year": 2018,
    "month": 6,
    "day": 4
  },
  "postalCode": "94303",
  "administrativeArea": "CA",
  "statisticalArea": "06085511100",
  "regionCode": "US",
  "solarPotential": {
    "maxArrayPanelsCount": 1373,
    "maxArrayAreaMeters2": 2247.3264,
    "maxSunshineHoursPerYear": 1809.6869,
    "carbonOffsetFactorKgPerMwh": 428.9201,
    "wholeRoofStats": {
      "areaMeters2": 2861.0686,
      "sunshineQuantiles": [
        384.4651,
        1385.7468,
        1465.545,
        1523.7301,
        1553.636,
        1589.27,
        1619.2816,
        1640.2871,
        1663.76,
        1750.4572,
        1883.4658
      ],
      "groundAreaMeters2": 2740.45
    },
    "roofSegmentStats": [
      {
        "pitchDegrees": 11.54571,
        "azimuthDegrees": 269.49054,
        "stats": {
          "areaMeters2": 478.75748,
          "sunshineQuantiles": [
            477.1805,
            1391.751,
            1515.6603,
            1555.4863,
            1579.1082,
            1594.9426,
            1607.4075,
            1621.5597,
            1631.4178,
            1641.8871,
            1727.1367
          ],
          "groundAreaMeters2": 469.07
        },
        "center": {
          "latitude": 37.4449647,
          "longitude": -122.1393672
        },
        "boundingBox": {
          "sw": {
            "latitude": 37.4447303,
            "longitude": -122.1394371
          },
          "ne": {
            "latitude": 37.4451819,
            "longitude": -122.1392963
          }
        },
        "planeHeightAtCenterMeters": 8.942595
      },
    ],
   "solarPanelConfigs": [
      {
        "panelsCount": 4,
        "yearlyEnergyDcKwh": 1823.9904,
        "roofSegmentSummaries": [
          {
            "pitchDegrees": 12.41514,
            "azimuthDegrees": 179.66463,
            "panelsCount": 4,
            "yearlyEnergyDcKwh": 1823.9905,
            "segmentIndex": 2
          }
        ]
      },
      /.../
    ]
   "financialAnalyses": [
      {
        "monthlyBill": {
          "currencyCode": "USD",
          "units": "20"
        },
        "panelConfigIndex": -1
      },
      {
        "monthlyBill": {
          "currencyCode": "USD",
          "units": "25"
        },
        "panelConfigIndex": -1
      },
      {
        "monthlyBill": {
          "currencyCode": "USD",
          "units": "30"
        },
        "panelConfigIndex": -1
      },
      {
        "monthlyBill": {
          "currencyCode": "USD",
          "units": "35"
        },
        "panelConfigIndex": 0,
        "financialDetails": {
          "initialAcKwhPerYear": 1550.3918,
          "remainingLifetimeUtilityBill": {
            "currencyCode": "USD",
            "units": "2548"
          },
          "federalIncentive": {
            "currencyCode": "USD",
            "units": "1483"
          },
          "stateIncentive": {
            "currencyCode": "USD"
          },
          "utilityIncentive": {
            "currencyCode": "USD"
          },
          "lifetimeSrecTotal": {
            "currencyCode": "USD"
          },
          "costOfElectricityWithoutSolar": {
            "currencyCode": "USD",
            "units": "10362"
          },
          "netMeteringAllowed": true,
          "solarPercentage": 86.94348,
          "percentageExportedToGrid": 52.350193
        },
        "leasingSavings": {
          "leasesAllowed": true,
          "leasesSupported": true,
          "annualLeasingCost": {
            "currencyCode": "USD",
            "units": "335",
            "nanos": 85540771
          },
          "savings": {
            "savingsYear1": {
              "currencyCode": "USD",
              "units": "-9"
            },
            "savingsYear20": {
              "currencyCode": "USD",
              "units": "1113"
            },
            "presentValueOfSavingsYear20": {
              "currencyCode": "USD",
              "units": "579",
              "nanos": 113281250
            },
            "financiallyViable": true,
            "savingsLifetime": {
              "currencyCode": "USD",
              "units": "1113"
            },
            "presentValueOfSavingsLifetime": {
              "currencyCode": "USD",
              "units": "579",
              "nanos": 113281250
            }
          }
        },
        "cashPurchaseSavings": {
          "outOfPocketCost": {
            "currencyCode": "USD",
            "units": "5704"
          },
          "upfrontCost": {
            "currencyCode": "USD",
            "units": "4221"
          },
          "rebateValue": {
            "currencyCode": "USD",
            "units": "1483",
            "nanos": 40039063
          },
          "paybackYears": 11.5,
          "savings": {
            "savingsYear1": {
              "currencyCode": "USD",
              "units": "326"
            },
            "savingsYear20": {
              "currencyCode": "USD",
              "units": "7815"
            },
            "presentValueOfSavingsYear20": {
              "currencyCode": "USD",
              "units": "1094",
              "nanos": 233276367
            },
            "financiallyViable": true,
            "savingsLifetime": {
              "currencyCode": "USD",
              "units": "7815"
            },
            "presentValueOfSavingsLifetime": {
              "currencyCode": "USD",
              "units": "1094",
              "nanos": 233276367
            }
          }
        },
        "financedPurchaseSavings": {
          "annualLoanPayment": {
            "currencyCode": "USD",
            "units": "335",
            "nanos": 85540771
          },
          "rebateValue": {
            "currencyCode": "USD"
          },
          "loanInterestRate": 0.05,
          "savings": {
            "savingsYear1": {
              "currencyCode": "USD",
              "units": "-9"
            },
            "savingsYear20": {
              "currencyCode": "USD",
              "units": "1113"
            },
            "presentValueOfSavingsYear20": {
              "currencyCode": "USD",
              "units": "579",
              "nanos": 113281250
            },
            "financiallyViable": true,
            "savingsLifetime": {
              "currencyCode": "USD",
              "units": "1113"
            },
            "presentValueOfSavingsLifetime": {
              "currencyCode": "USD",
              "units": "579",
              "nanos": 113281250
            }
          }
        }
      },
    ],
    /.../
    "panelCapacityWatts": 250,
    "panelHeightMeters": 1.65,
    "panelWidthMeters": 0.992,
    "panelLifetimeYears": 20,
    "buildingStats": {
      "areaMeters2": 2945.2869,
      "sunshineQuantiles": [
        372.5415,
        1371.2333,
        1456.3909,
        1519.6279,
        1550.9833,
        1586.4949,
        1617.6183,
        1639.3303,
        1662.812,
        1748.7468,
        1892.1855
      ],
      "groundAreaMeters2": 2789.4
    },
    "solarPanels": [
      {
        "center": {
          "latitude": 37.4449709,
          "longitude": -122.13907649999999
        },
        "orientation": "LANDSCAPE",
        "yearlyEnergyDcKwh": 456.5196,
        "segmentIndex": 2
      },
      /.../
    ]
  "imageryQuality": "HIGH",
  "imageryProcessedDate": {
    "year": 2022,
    "month": 10,
    "day": 16
  }
}

Cobalah!

API Explorer memungkinkan Anda membuat permintaan contoh sehingga Anda dapat memahami opsi API dan API.

  1. Secara opsional, edit parameter permintaan.

  2. Pilih tombol Execute. Di kotak dialog pop-up, pilih akun yang ingin digunakan untuk membuat permintaan.