bool r_points::add(IGeometry* pGeom) { double x = std::numeric_limits<double>::quiet_NaN(); double y = std::numeric_limits<double>::quiet_NaN(); double z = std::numeric_limits<double>::quiet_NaN(); double m = std::numeric_limits<double>::quiet_NaN(); if (pGeom != NULL) { VARIANT_BOOL b = VARIANT_FALSE; pGeom->get_IsEmpty(&b); if (b == VARIANT_FALSE) { CComQIPtr<IPoint> ipPoint(pGeom); ipPoint->QueryCoords(&x, &y); if (is_z) ipPoint->get_Z(&z); if (is_m) ipPoint->get_M(&m); } } m_x.push_back(x); m_y.push_back(y); if (is_z) m_z.push_back(z); if (is_m) m_m.push_back(m); return true; }
///////////////////////////////////////////////////////////////////////////// // IMarkerMask STDMETHODIMP CLogoMarkerSymbol::QueryMarkerMask(OLE_HANDLE hDC, ITransformation *Transform, IGeometry *Geometry, IPolygon *Boundary) { //Code QueryBoundary using same steps as Draw. But add a step where //Points are converted to Map units, and then build an appropriate Polygon. if (Geometry == NULL || Boundary == NULL) return E_FAIL; IDisplayTransformationPtr ipDTrans(Transform); if (ipDTrans == NULL) return E_FAIL; IPointPtr ipPoint(Geometry); if (ipPoint == NULL) return E_FAIL; Boundary->SetEmpty(); QueryBoundsFromGeom(hDC, ipDTrans, Boundary, ipPoint); //Unlike ISymbol_QueryBoundary, QueryMarkerMask requires a Simple geometry. ITopologicalOperatorPtr ipTopo(Boundary); VARIANT_BOOL bSimple; ipTopo->get_IsKnownSimple(&bSimple); if (bSimple == VARIANT_FALSE) { ipTopo->get_IsSimple(&bSimple); if (bSimple == VARIANT_FALSE) { ipTopo->Simplify(); } } return S_OK; }
long shape_extractor::at(size_t i, IGeometry **ppNewGeom) { if (m_gt == esriGeometryNull) return S_FALSE; CComQIPtr<IGeometry> ipNewShape; if (m_gt == esriGeometryPoint) { HRESULT hr = newShape(m_gt, m_ipSR, m_hasZ, m_hasM, &ipNewShape); if (hr != S_OK) return showError<true>(L"create new geometry failed"), hr; CComQIPtr<IPoint> ipPoint(ipNewShape); double x, y, z, m; if (m_as_matrix) { ATLASSERT(Rf_isMatrix(m_shape)); size_t r = m_len;//INTEGER(dims)[0]; x = REAL(m_shape)[i]; y = REAL(m_shape)[i + r]; if (m_hasZ || m_hasM) { m = z = REAL(m_shape)[i + (r*2)]; if (m_hasZ && m_hasM) m = REAL(m_shape)[i + (r*3)]; } } else { x = REAL(m_parts[0])[i]; y = REAL(m_parts[1])[i]; if (m_hasZ || m_hasM) { double z, m; m = z = REAL(m_parts[2])[i]; if (m_hasZ && m_hasM) m = REAL(m_parts[3])[i]; } } ipPoint->PutCoords(x, y); if (m_hasZ) ipPoint->put_Z(z); if (m_hasM) ipPoint->put_M(m); return ipNewShape.CopyTo(ppNewGeom); } SEXP it = 0; tools::vectorGeneric geometry(m_shape); HRESULT hr = newShape(m_gt, m_ipSR, false, false, &ipNewShape); if (hr != S_OK) return showError<true>(L"create new geometry failed"), hr; it = geometry.at(i); if (Rf_isNull(it)) { ipNewShape->SetEmpty(); } else { HRESULT hr = S_FALSE; if (TYPEOF(it) == NILSXP || Rf_isNumeric(it)) hr = ipNewShape->SetEmpty(); else { std::vector<BYTE> buff; if (!tools::copy_to(it, buff)) return showError<false>(L"unknown structure"), E_FAIL; CComQIPtr<IESRIShape2> ipShape(ipNewShape); long buffSize = (long)buff.size(); hr = ipShape->ImportFromESRIShapeEx(esriShapeImportNoSwap | esriShapeImportNonTrusted, &buffSize, &buff[0]); } if (hr != S_OK) return showError<true>(L"create new geometry"), hr; } return ipNewShape.CopyTo(ppNewGeom); }