コード例 #1
0
ファイル: h3.cpp プロジェクト: RussWhitehead/HPCC-Platform
//  Regions  ---
ECL_H3_API void ECL_H3_CALL polyfill(ICodeContext *_ctx, bool &__isAllResult, size32_t &__lenResult, void *&__result, size32_t countBoundary, const byte **boundary, uint32_t resolution)
{
    GeoCoord *verts = static_cast<GeoCoord *>(rtlCalloc(countBoundary, sizeof(GeoCoord)));
    for (int i = 0; i < countBoundary; ++i)
    {
        GeoCoord *row = (GeoCoord *)boundary[i];
        verts[i].lat = ::degsToRads(row->lat);
        verts[i].lon = ::degsToRads(row->lon);
    }

    Geofence geofence;
    geofence.numVerts = countBoundary;
    geofence.verts = verts;

    GeoPolygon polygon;
    polygon.geofence = geofence;
    polygon.numHoles = 0;

    int maxBuff = ::maxPolyfillSize(&polygon, resolution);
    H3Index *buff = static_cast<H3Index *>(rtlCalloc(maxBuff, sizeof(H3Index)));
    ::polyfill(&polygon, resolution, buff);
    toSetOf(__isAllResult, __lenResult, __result, buff, maxBuff);

    rtlFree(verts);
}
コード例 #2
0
ファイル: h3.cpp プロジェクト: AttilaVamos/HPCC-Platform
ECL_H3_API void ECL_H3_CALL polyfill(ICodeContext *_ctx, bool &__isAllResult, size32_t &__lenResult, void *&__result, size32_t countBoundary, const byte **boundary, uint32_t resolution)
{
    //  Check for special case when points exceed 180 degrees (longtitude)
    //   - https://github.com/uber/h3/issues/210
    GeoCoord *poly = static_cast<GeoCoord *>(rtlCalloc(countBoundary, sizeof(GeoCoord)));
    GeoCoord *wPoly = static_cast<GeoCoord *>(rtlCalloc(countBoundary, sizeof(GeoCoord)));
    GeoCoord *ePoly = static_cast<GeoCoord *>(rtlCalloc(countBoundary, sizeof(GeoCoord)));
    double west = 0;
    double east = 0;
    for (int i = 0; i < countBoundary; ++i)
    {
        const GeoCoord *row = (GeoCoord *)boundary[i];
        double lat = ::degsToRads(row->lat);
        double lon = ::degsToRads(row->lon);
        poly[i].lat = lat;
        poly[i].lon = lon;
        wPoly[i].lat = lat;
        wPoly[i].lon = lon > 0 ? 0 : lon;
        ePoly[i].lat = lat;
        ePoly[i].lon = lon <= 0 ? 0 : lon;

        if (i == 0)
            west = east = row->lon;
        else if (west > row->lon)
            west = lon;
        else if (east < row->lon)
            east = lon;
    }
    if (east - west >= 180)
    {
        GeoPolygon wPolygon, ePolygon;
        int wMaxBuff = initPolygon(wPoly, countBoundary, resolution, wPolygon);
        int eMaxBuff = initPolygon(ePoly, countBoundary, resolution, ePolygon);
        H3Index *buff = static_cast<H3Index *>(rtlCalloc(wMaxBuff + eMaxBuff, sizeof(H3Index)));
        ::polyfill(&wPolygon, resolution, buff);
        ::polyfill(&ePolygon, resolution, buff + wMaxBuff);
        toSetOf(__isAllResult, __lenResult, __result, buff, wMaxBuff + eMaxBuff);
    }
    else
    {
        GeoPolygon polygon;
        int maxBuff = initPolygon(poly, countBoundary, resolution, polygon);
        H3Index *buff = static_cast<H3Index *>(rtlCalloc(maxBuff, sizeof(H3Index)));
        ::polyfill(&polygon, resolution, buff);
        toSetOf(__isAllResult, __lenResult, __result, buff, maxBuff);
    }
    rtlFree(ePoly);
    rtlFree(wPoly);
    rtlFree(poly);
}
コード例 #3
0
ファイル: h3.cpp プロジェクト: AttilaVamos/HPCC-Platform
ECL_H3_API void ECL_H3_CALL compact(ICodeContext *_ctx, bool &__isAllResult, size32_t &__lenResult, void *&__result, bool isAllIndexSet, size32_t lenIndexSet, const void *indexSet)
{
    const int len = lenIndexSet / sizeof(H3Index);
    H3Index *buff = static_cast<H3Index *>(rtlCalloc(len, sizeof(H3Index)));
    ::compact(static_cast<const H3Index *>(indexSet), buff, len);
    toSetOf(__isAllResult, __lenResult, __result, buff, len);
}
コード例 #4
0
ファイル: h3.cpp プロジェクト: AttilaVamos/HPCC-Platform
ECL_H3_API void ECL_H3_CALL children(ICodeContext *_ctx, bool &__isAllResult, size32_t &__lenResult, void *&__result, unsigned __int64 index, uint32_t resolution)
{
    int maxBuff = ::maxH3ToChildrenSize(index, resolution);
    H3Index *buff = static_cast<H3Index *>(rtlCalloc(maxBuff, sizeof(H3Index)));
    ::h3ToChildren(index, resolution, buff);
    toSetOf(__isAllResult, __lenResult, __result, buff, maxBuff);
}
コード例 #5
0
ファイル: h3.cpp プロジェクト: AttilaVamos/HPCC-Platform
ECL_H3_API void ECL_H3_CALL hexRing(ICodeContext *_ctx, bool &__isAllResult, size32_t &__lenResult, void *&__result, unsigned __int64 index, uint32_t k)
{
    int maxBuff = ::maxKringSize(k);
    H3Index *buff = static_cast<H3Index *>(rtlCalloc(maxBuff, sizeof(H3Index)));
    ::hexRing(index, k, buff);
    toSetOf(__isAllResult, __lenResult, __result, buff, maxBuff);
}
コード例 #6
0
ファイル: h3.cpp プロジェクト: AttilaVamos/HPCC-Platform
ECL_H3_API void ECL_H3_CALL uncompact(ICodeContext *_ctx, bool &__isAllResult, size32_t &__lenResult, void *&__result, bool isAllIndexSet, size32_t lenIndexSet, const void *indexSet, uint32_t resolution)
{
    const int len = lenIndexSet / sizeof(H3Index);
    int maxBuff = ::maxUncompactSize(static_cast<const H3Index *>(indexSet), len, resolution);
    H3Index *buff = static_cast<H3Index *>(rtlCalloc(maxBuff, sizeof(H3Index)));
    ::uncompact(static_cast<const H3Index *>(indexSet), len, buff, maxBuff, resolution);
    toSetOf(__isAllResult, __lenResult, __result, buff, maxBuff);
}