MCPcopy Create free account
hub / github.com/GeoDaCenter/geoda / GetExtentOfSelected

Method GetExtentOfSelected

Explore/MapLayer.cpp:140–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138}
139
140void BackgroundMapLayer::GetExtentOfSelected(double &_minx, double &_miny, double &_maxx,
141 double &_maxy)
142{
143 bool has_selected = false;
144 int cnt = 0;
145 for (int i=0; i<highlight_flags.size(); i++) {
146 if (highlight_flags[i] && geoms[i]) {
147 has_selected = true;
148 OGRwkbGeometryType eType = wkbFlatten(geoms[i]->getGeometryType());
149 if (eType == wkbPoint) {
150 OGRPoint* p = (OGRPoint *) geoms[i];
151 if (cnt == 0) {
152 _minx = p->getX();
153 _miny = p->getY();
154 _maxx = p->getX();
155 _maxy = p->getY();
156 } else {
157 if (p->getX() < _minx) _minx = p->getX();
158 if (p->getY() < _miny) _miny = p->getY();
159 if (p->getX() > _maxx) _maxx = p->getX();
160 if (p->getY() > _maxy) _maxy = p->getY();
161 }
162 } else {
163 OGREnvelope box;
164 geoms[i]->getEnvelope(&box);
165 if (cnt == 0) {
166 _minx =box.MinX;
167 _miny =box.MinY;
168 _maxx =box.MaxX;
169 _maxy =box.MaxY;
170 } else {
171 if (box.MinX < _minx) _minx = box.MinX;
172 if (box.MinY < _miny) _miny = box.MinY;
173 if (box.MaxX > _maxx) _maxx = box.MaxX;
174 if (box.MaxY > _maxy) _maxy = box.MaxY;
175 }
176 }
177 cnt += 1;
178 }
179 }
180 if (has_selected == false) {
181 // fall back to layer extent
182 GetExtent(_minx, _miny, _maxx, _maxy);
183 }
184}
185
186int BackgroundMapLayer::GetHighlightRecords()
187{

Callers 1

OnZoomToSelectedMethod · 0.45

Calls 2

getXMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected