Sparql 我怎样才能得到一个国家的邻国?

Sparql 我怎样才能得到一个国家的邻国?,sparql,dbpedia,Sparql,Dbpedia,在我的工作中,我需要从dbpedia中找到一个国家的属性,如货币、人口等邻国。我如何才能做到这一点? 一个解决方案可能是这样的。。 一个sparql查询,它从dbpedia获取所有国家的经度和纬度,并找到科迪纳群岛靠近德国的国家。怎么样?但是我对sparql是新手?所以,我不确定,这个问题将如何解决 仅供参考:我不需要所有的邻居。三个邻居对我来说就足够了。只查询dbpedia,不可能得到邻居的国家。最简单的方法可能是,获得经度和纬度。通过数学方程找到距离。下面是获取距离的方法 private d

在我的工作中,我需要从dbpedia中找到一个国家的属性,如货币、人口等邻国。我如何才能做到这一点? 一个解决方案可能是这样的。。 一个sparql查询,它从dbpedia获取所有国家的经度和纬度,并找到科迪纳群岛靠近德国的国家。怎么样?但是我对sparql是新手?所以,我不确定,这个问题将如何解决


仅供参考:我不需要所有的邻居。三个邻居对我来说就足够了。

只查询dbpedia,不可能得到邻居的国家。最简单的方法可能是,获得经度和纬度。通过数学方程找到距离。下面是获取距离的方法

private double getDistance(double submittedCountryLat,double submittedCountryLong,double countryLat,double countryLong){

        double distance = 0;
        double submittedCountryLatRadian=Math.toRadians(submittedCountryLat);       
        double submittedCountryLongRadian=Math.toRadians(submittedCountryLong);
        double countryLatRadian=Math.toRadians(countryLat);
        double countryLongRadian=Math.toRadians(countryLong);

        double absoluteDistanceLat=submittedCountryLatRadian-countryLatRadian;
        double absoluteDistanceLong=submittedCountryLongRadian-countryLongRadian;

        distance=Math.sin(absoluteDistanceLat/2)*Math.sin(absoluteDistanceLat/2) +
                Math.cos(submittedCountryLatRadian)*Math.cos(countryLatRadian)* Math.sin(absoluteDistanceLong/2)*Math.sin(absoluteDistanceLong/2);

        distance=2* Math.asin(Math.sqrt(distance));
        return distance*6371;

    }

然后用国家名称对所有距离进行排序,并取距离最短的国家名称

您是否只对德国的邻国感兴趣(在这种情况下,我现在可以告诉您,您不需要DBpedia),或者这只是一个随机提及的示例?这只是一个示例
private double getDistance(double submittedCountryLat,double submittedCountryLong,double countryLat,double countryLong){

        double distance = 0;
        double submittedCountryLatRadian=Math.toRadians(submittedCountryLat);       
        double submittedCountryLongRadian=Math.toRadians(submittedCountryLong);
        double countryLatRadian=Math.toRadians(countryLat);
        double countryLongRadian=Math.toRadians(countryLong);

        double absoluteDistanceLat=submittedCountryLatRadian-countryLatRadian;
        double absoluteDistanceLong=submittedCountryLongRadian-countryLongRadian;

        distance=Math.sin(absoluteDistanceLat/2)*Math.sin(absoluteDistanceLat/2) +
                Math.cos(submittedCountryLatRadian)*Math.cos(countryLatRadian)* Math.sin(absoluteDistanceLong/2)*Math.sin(absoluteDistanceLong/2);

        distance=2* Math.asin(Math.sqrt(distance));
        return distance*6371;

    }