Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/195.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 具有多多边形计算的领域和大型数据集_Android_Realm_Coordinates_Polygon_Large Data - Fatal编程技术网

Android 具有多多边形计算的领域和大型数据集

Android 具有多多边形计算的领域和大型数据集,android,realm,coordinates,polygon,large-data,Android,Realm,Coordinates,Polygon,Large Data,我正在解析一个Json文件,该文件包含许多指向领域的多义函数。我已按以下方式设置: RealmMultiPolygon类: public int dangerLevel; public int timeOfDay; public RealmList<RealmPolygon> realmPolygons public RealmList<RealmPolygonCoordinate> coordinates; 就有关项目而言: RealmMultiPolygon包

我正在解析一个Json文件,该文件包含许多指向领域的多义函数。我已按以下方式设置:

RealmMultiPolygon类:

public int dangerLevel;
public int timeOfDay;

public RealmList<RealmPolygon> realmPolygons
public RealmList<RealmPolygonCoordinate> coordinates;
就有关项目而言:

  • RealmMultiPolygon包含8项
  • RealmPolygon包含22260项
  • RealmPolygonCoordinate包含352241项
我试图弄清楚一个RealmPolygon是否在我所观察的方向上,以及在我当前位置附近。我采集了31个方位像这样的样本:

private void calculateUserDirectionLocations() {
    Log.d(Constants.DEBUG, "update the locationbar");
    if(compassData < 0) {
        return;
    }
    int step = 50;

    int bearingstep = 1;

    double bearing = Math.round(compassData / bearingstep) * bearingstep;

    if(userLocation != null) {
        if(Math.abs(bearing - oldBearing) > 1) {
            locationSamples.clear();

            Log.d(Constants.DEBUG, "START location samples");

            for(int i = 0; i <= Constants.MAX_DISTANCE; i+=step) {
                if (i % step == 0) {
                    locationSamples.add(locationWithBearing((double) i));
                }
            }

            Log.d(Constants.DEBUG, "END location samples");

            updateColors();
            oldBearing = bearing;
        }
    }
}
for(RealmMultiPolygon rmp : area.avalanche.multiPolygon) {
                if(rmp.timeOfDay == 2) {
                    for (RealmPolygon polygon : rmp.realmPolygons) {
                        for(LatLng sample : locationSamples) {
                            tempPoint = new LatLng(polygon.coordinates.first().latitude, polygon.coordinates.first().longitude);
                            if(SphericalUtil.computeDistanceBetween(tempPoint, sample) <= 500) {
                                coords.add(tempPoint);
                            } else {
                                break;
                            }
                        }
                    }
                }
            }
private void calculateUserDirectionLocations(){
Log.d(Constants.DEBUG,“更新位置栏”);
if(compassData<0){
返回;
}
int步长=50;
int轴承步骤=1;
双轴承=数学四舍五入(compassData/bearingstep)*轴承步骤;
if(userLocation!=null){
如果(数学abs(轴承-旧轴承)>1){
locationSamples.clear();
Log.d(Constants.DEBUG,“开始位置示例”);

对于(int i=0;i我最终解决了这个问题,提出了一个完全不同的解决方案。我现在根据多边形所在区域的宽度和高度创建一个图像作为背景任务。然后根据我获取的locationsample计算像素位置,并使用getPixel方法获取该位置上的像素。这要快得多而不是在每个多边形中循环。

你可以使它并行。我必须在我的领域数据库中当前拥有的所有多边形坐标中循环31次。你怎么做?你能显示在领域和循环中进行查询的代码块吗?什么是
区域。雪崩。多多边形
?@TimCastelijns这是RealmList,它是包含多个多边形。
for(RealmMultiPolygon rmp : area.avalanche.multiPolygon) {
                if(rmp.timeOfDay == 2) {
                    for (RealmPolygon polygon : rmp.realmPolygons) {
                        for(LatLng sample : locationSamples) {
                            tempPoint = new LatLng(polygon.coordinates.first().latitude, polygon.coordinates.first().longitude);
                            if(SphericalUtil.computeDistanceBetween(tempPoint, sample) <= 500) {
                                coords.add(tempPoint);
                            } else {
                                break;
                            }
                        }
                    }
                }
            }