2016-07-20 6 views
0

S2Regionはどのようなものを使用すればよいですか?緯度、経度、半径(km/km)はgoogleのs2ライブラリを使用していますか?google s2ライブラリを使用する - 円内の特定のレベルのすべてのs2セルを見つけ、緯度/経度と半径をkm/kmで表します。

S2Region region = ? 
S2RegionCoverer coverer = new S2RegionCoverer(); 
coverer.setMinLevel(17); 
coverer.setMaxCells(17); 
S2CellUnion covering = coverer.getCovering(region_cap); 

おかげ

+1

@tarantulaは - あなたのポストに続いhttp://blog.christianperone.com/2015/08/googles-s2 -geometry-on-the-sphere-cells-and-hilbert-curve /は円形領域でどのように行うのか把握できませんでした。同じようにあなたの助けを感謝します。 – Darshan

答えて

1

はここNPMパッケージs2geometryノードからC++の例です。コードは、私は同じタスクが発生し、S2RegionCoverer.getCovering(S2Region region, ArrayList<S2CellId> covering)方法の使用とそれを解決していた

const double kEarthCircumferenceMeters = 1000 * 40075.017; 

double EarthMetersToRadians(double meters) { 
    return (2 * M_PI) * (meters/kEarthCircumferenceMeters); 
} 

string CellToString(const S2CellId& id) { 
    return StringPrintf("%d:%s", id.level(), id.ToToken().c_str()); 
} 

// Generates a list of cells at the target s2 cell levels which cover 
// a cap of radius 'radius_meters' with center at lat & lng. 
vector<string> SearchCells(double lat, double lng, double radius_meters, 
          int min_level, int max_level) { 
    const double radius_radians = EarthMetersToRadians(radius_meters); 
    const S2Cap region = S2Cap::FromAxisHeight(
     S2LatLng::FromDegrees(lat, lng).Normalized().ToPoint(), 
     (radius_radians * radius_radians)/2); 
    S2RegionCoverer coverer; 
    coverer.set_min_level(min_level); 
    coverer.set_max_level(max_level); 

    vector<S2CellId> covering; 
    coverer.GetCovering(region, &covering); 
    vector<string> v(covering.size()); 
    for (size_t i = 0; i < covering.size(); ++i) { 
    v[i] = CellToString(covering[i]); 
    } 
    return v; 
} 
0

ファインダー/ viewfinder.ccからコピーされました。

あなたは S2RegionCoverer.getCovering(S2Region region)マニュアルに記載されて異なるレベルのセルを取得した理由問題

/** 
    * Return a normalized cell union that covers the given region and satisfies 
    * the restrictions *EXCEPT* for min_level() and level_mod(). These criteria 
    * cannot be satisfied using a cell union because cell unions are 
    * automatically normalized by replacing four child cells with their parent 
    * whenever possible. (Note that the list of cell ids passed to the cell union 
    * constructor does in fact satisfy all the given restrictions.) 
    */ 
関連する問題