/* * Copyright 2016-2017 Uber Technologies, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** @file * @brief functions to generate simple KML files */ #include "kml.h" #include #include "h3api.h" void kmlPtsHeader(const char* name, const char* desc) { printf("\n"); printf( "\n"); printf("\n"); printf(" %s\n", name); printf(" %s\n", desc); printf(" \n"); printf(" \n"); printf(" \n"); printf(" normal\n"); printf(" #s_circle\n"); printf(" \n"); printf(" \n"); printf(" highlight\n"); printf(" #s_circle_hl\n"); printf(" \n"); printf(" \n"); printf(" \n"); } void kmlBoundaryHeader(const char* name, const char* desc) { printf("\n"); printf("\n"); printf("\n"); printf(" %s\n", name); printf(" %s\n", desc); printf(" \n"); } void kmlPtsFooter(void) { printf("\n"); printf("\n"); } void kmlBoundaryFooter(void) { printf("\n"); printf("\n"); } void outputLatLonKML(const GeoCoord* g) { printf(" %8lf,%8lf,5.0\n", H3_EXPORT(radsToDegs)(g->lon), H3_EXPORT(radsToDegs)(g->lat)); } void outputPointKML(const GeoCoord* g, const char* name) { printf("\n"); printf(" %s\n", name); printf(" #m_ylw-pushpin\n"); printf(" \n"); printf(" relativeToGround\n"); printf(" \n"); outputLatLonKML(g); printf(" \n"); printf(" \n"); printf("\n"); } void outputTriKML(const GeoCoord* v1, const GeoCoord* v2, const GeoCoord* v3, const char* name) { printf("\n"); printf("%s\n", name); printf(" #lineStyle1\n"); printf(" \n"); printf(" 1\n"); printf(" \n"); outputLatLonKML(v1); outputLatLonKML(v2); outputLatLonKML(v3); outputLatLonKML(v1); printf(" \n"); printf(" \n"); printf("\n"); } void outputBoundaryKML(const GeoBoundary* b, const char* name) { const GeoCoord* v = (const GeoCoord*)&(b->verts); outputPolyKML(v, b->numVerts, name); } void outputPolyKML(const GeoCoord geoVerts[], int numVerts, const char* name) { printf("\n"); printf("%s\n", name); printf(" #lineStyle1\n"); printf(" \n"); printf(" 1\n"); printf(" \n"); for (int v = 0; v < numVerts; v++) outputLatLonKML(&geoVerts[v]); outputLatLonKML(&geoVerts[0]); printf(" \n"); printf(" \n"); printf("\n"); }