MapBox interiorPolygons не может отображать дыру в какой-то области

Платформа: xcode 9.2 iOS target-c Версия Mapbox SDK: Mapbox-iOS-SDK (3.7.2)

Ожидаемое поведение Я хочу выкопать несколько дыр в некоторой области в тумане мира, большая часть области может появиться. Но некоторые области не могут показать отверстие. Например код ниже: Отверстие Шестиугольника на улице Малая Полянка, 5, Москва, Россия, 119180 Широта: 55.735024 | Долгота: 37,617188.

Реальное поведение В районе нет дыр Улица Малая Полянка, 5, Москва, Россия, 119180 Широта: 55.735024 | Долгота: 37,617188.

CLLocationCoordinate2D lightCoordinate[6] = { {55.735024042991469,  37.617187500000007}, {55.742165827861974,37.595214843749993}, {55.75644547726997, 37.595214843749993}, {55.763583342064059, 37.617187500000007}, {55.75644547726997, 37.639160156249993}, {55.742165827861974, 37.639160156249993} };
NSUInteger numberOfLightCoordinates = sizeof(lightCoordinate) / sizeof(CLLocationCoordinate2D);
    MGLPolygon *lightPolygon = [MGLPolygon polygonWithCoordinates:lightCoordinate count:numberOfLightCoordinates];
NSArray<MGLPolygon *> *lightPolygonArray = @[lightPolygon];

CLLocationCoordinate2D worldCoords[6] = { {90, 0}, {90, 180}, {-90,180}, {-90,0}, {-90,-180}, {90,-180} };
        NSUInteger numberOfWorldCoords = sizeof(worldCoords) / sizeof(CLLocationCoordinate2D);
        MGLPolygon *worldOverlay = [MGLPolygon polygonWithCoordinates:worldCoords
                                                         count:numberOfWorldCoords
                                              interiorPolygons:lightPolygonArray];
        //the array can have more than one "cutout" if needed

        [self.mapBoxView addOverlay:self.worldOverlay];

person Zgpeace    schedule 08.01.2018    source источник


Ответы (1)


Я решаю проблему с некоторой хитростью. Разделите землю на северную и южную части. Каждая часть с вырезанными массивами. Код показан ниже

CLLocationCoordinate2D northWorldCoords[4] = { {0, -180}, {0, 180}, {90, 180}, {90, -180}};
        NSUInteger northNumberOfWorldCoords = sizeof(northWorldCoords) / sizeof(CLLocationCoordinate2D);
        _northWorldOverlay = [MGLPolygon polygonWithCoordinates:northWorldCoords
                                                         count:northNumberOfWorldCoords
                                              interiorPolygons:northLightPolygonArray];
        //the array can have more than one "cutout" if needed

        [self.chillViewController.mapBoxView addOverlay:_northWorldOverlay];

        CLLocationCoordinate2D southWorldCoords[4] = {{0, -180}, {0, 180}, {-90, 180}, {-90, -180}};
        NSUInteger southNumberOfWorldCoords = sizeof(southWorldCoords) / sizeof(CLLocationCoordinate2D);
        _southWorldOverlay = [MGLPolygon polygonWithCoordinates:southWorldCoords
                                                         count:southNumberOfWorldCoords
                                              interiorPolygons:southLightPolygonArray];
        //the array can have more than one "cutout" if needed

        [self.chillViewController.mapBoxView addOverlay:_southWorldOverlay];
person Zgpeace    schedule 08.01.2018