/** * Set the output cube to specified file name and specified input images * and output attributes and lat,lons */ Isis::Cube *ProcessMapMosaic::SetOutputCube(const QString &inputFile, double xmin, double xmax, double ymin, double ymax, double slat, double elat, double slon, double elon, int nbands, CubeAttributeOutput &oAtt, const QString &mosaicFile) { Pvl fileLab(inputFile); PvlGroup &mapping = fileLab.findGroup("Mapping", Pvl::Traverse); mapping["UpperLeftCornerX"] = toString(xmin); mapping["UpperLeftCornerY"] = toString(ymax); mapping.addKeyword(PvlKeyword("MinimumLatitude", toString(slat)), Pvl::Replace); mapping.addKeyword(PvlKeyword("MaximumLatitude", toString(elat)), Pvl::Replace); mapping.addKeyword(PvlKeyword("MinimumLongitude", toString(slon)), Pvl::Replace); mapping.addKeyword(PvlKeyword("MaximumLongitude", toString(elon)), Pvl::Replace); Projection *firstProj = ProjectionFactory::CreateFromCube(fileLab); int samps = (int)(ceil(firstProj->ToWorldX(xmax) - firstProj->ToWorldX(xmin)) + 0.5); int lines = (int)(ceil(firstProj->ToWorldY(ymin) - firstProj->ToWorldY(ymax)) + 0.5); delete firstProj; if (p_createMosaic) { Pvl newMap; newMap.addGroup(mapping); // Initialize the mosaic CubeAttributeInput inAtt; ProcessByLine p; p.SetInputCube(inputFile, inAtt); p.PropagateHistory(false); p.PropagateLabels(false); p.PropagateTables(false); p.PropagatePolygons(false); p.PropagateOriginalLabel(false); // If track set, create the origin band if (GetTrackFlag()) { nbands += 1; } // For average priority, get the new band count else if (GetImageOverlay() == AverageImageWithMosaic) { nbands *= 2; } Cube *ocube = p.SetOutputCube(mosaicFile, oAtt, samps, lines, nbands); p.Progress()->SetText("Initializing mosaic"); p.ClearInputCubes(); p.StartProcess(ProcessMapMosaic::FillNull); // CreateForCube created some keywords in the mapping group that needs to be added ocube->putGroup(newMap.findGroup("Mapping", Pvl::Traverse)); p.EndProcess(); } Cube *mosaicCube = new Cube(); mosaicCube->open(mosaicFile, "rw"); mosaicCube->addCachingAlgorithm(new UniqueIOCachingAlgorithm(2)); AddOutputCube(mosaicCube); return mosaicCube; }
void Node::buildPath(const Projection& aProjection) { if (ProjectionRevision != aProjection.projectionRevision()) { Projected = aProjection.project(BBox.topLeft()); ProjectionRevision = aProjection.projectionRevision(); } }
void ScanAndOrder::fill( BufBuilder& b, const ParsedQuery *parsedQuery, int& nout ) const { int n = 0; int nFilled = 0; Projection *projection = parsedQuery ? parsedQuery->getFields() : NULL; scoped_ptr<Matcher> arrayMatcher; scoped_ptr<MatchDetails> details; if ( projection && projection->getArrayOpType() == Projection::ARRAY_OP_POSITIONAL ) { // the projection specified an array positional match operator; create a new matcher // for the projected array arrayMatcher.reset( new Matcher( parsedQuery->getFilter() ) ); details.reset( new MatchDetails ); details->requestElemMatchKey(); } for ( BestMap::const_iterator i = _best.begin(); i != _best.end(); i++ ) { n++; if ( n <= _startFrom ) continue; const BSONObj& o = i->second; massert( 16355, "positional operator specified, but no array match", ! arrayMatcher || arrayMatcher->matches( o, details.get() ) ); fillQueryResultFromObj( b, projection, o, details.get() ); nFilled++; if ( nFilled >= _limit ) break; } nout = nFilled; }
void ListSelections::setProjectionList( ListProjections* l ) { m_lpListProjections = l; CatalogInstance* lpCatalog = NULL; lpCatalog = CatalogInstance::getCatalog(); //new CatalogInstance(); if (lpCatalog == NULL) parser_error("Unable to create Catalog."); if( m_iSelectAll ) { m_iSelectAll = 0; list<Projection*> lp = m_lpListProjections->getProjections(); for( list<Projection*>::iterator i = lp.begin(); i != lp.end(); i++ ) { Projection* p = (*i); string name = p->getAlias(); if( name == "" ) { name = p->get(); } vector<string>* lpListColumnNames = lpCatalog->getColumnNames(p->get()); for(vector<string>::iterator i = lpListColumnNames->begin(); i != lpListColumnNames->end(); ++i) { EColumn* col = EColumn::create(name, *i); EHolder* lpHolder = EHolder::create(col); addSelection(lpHolder); } } } }
bool Projection::operator==(const Projection &Other) const { if (isNominalKind() && Other.isNominalKind()) { return Other.getDecl() == Decl; } else { return !Other.isNominalKind() && Index == Other.getIndex(); } }
void ScreenMVCullVisitor::apply(Projection& node) { // push the culling mode. pushCurrentMask(); // push the node's state. StateSet* node_state = node.getStateSet(); if(node_state) pushStateSet(node_state); // record previous near and far values. float previous_znear = _computed_znear; float previous_zfar = _computed_zfar; // take a copy of the current near plane candidates DistanceMatrixDrawableMap previousNearPlaneCandidateMap; previousNearPlaneCandidateMap.swap(_nearPlaneCandidateMap); _computed_znear = FLT_MAX; _computed_zfar = -FLT_MAX; ref_ptr < RefMatrix > matrix = createOrReuseMatrix(node.getMatrix()); pushProjectionMatrix(matrix.get()); //OSG_NOTIFY(osg::INFO)<<"Push projection "<<*matrix<<std::endl; // note do culling check after the frustum has been updated to ensure // that the node is not culled prematurely. bool status = _cullingStatus; bool firstStatus = _firstCullStatus; if(!isCulled(node)) { handle_cull_callbacks_and_traverse(node); } _firstCullStatus = firstStatus; _cullingStatus = status; popProjectionMatrix(); //OSG_NOTIFY(osg::INFO)<<"Pop projection "<<*matrix<<std::endl; _computed_znear = previous_znear; _computed_zfar = previous_zfar; // swap back the near plane candidates previousNearPlaneCandidateMap.swap(_nearPlaneCandidateMap); // pop the node's state off the render graph stack. if(node_state) popStateSet(); // pop the culling mode. popCurrentMask(); }
static void test_simple() { Projection prj; prj.SetGeoLocation(GeoPoint::Zero()); TestGeoScreenCouple(prj, GeoPoint(Angle::Zero(), Angle::Zero()), 0, 0); }
void DrawGeoBitmap(const RawBitmap &bitmap, PixelSize bitmap_size, const GeoBounds &bounds, const Projection &projection) { assert(bounds.IsValid()); const BulkPixelPoint vertices[] = { projection.GeoToScreen(bounds.GetNorthWest()), projection.GeoToScreen(bounds.GetNorthEast()), projection.GeoToScreen(bounds.GetSouthWest()), projection.GeoToScreen(bounds.GetSouthEast()), }; const ScopeVertexPointer vp(vertices); const GLTexture &texture = bitmap.BindAndGetTexture(); const PixelSize allocated = texture.GetAllocatedSize(); const GLfloat src_x = 0, src_y = 0, src_width = bitmap_size.cx, src_height = bitmap_size.cy; GLfloat x0 = src_x / allocated.cx; GLfloat y0 = src_y / allocated.cy; GLfloat x1 = (src_x + src_width) / allocated.cx; GLfloat y1 = (src_y + src_height) / allocated.cy; const GLfloat coord[] = { x0, y0, x1, y0, x0, y1, x1, y1, }; #ifdef USE_GLSL OpenGL::texture_shader->Use(); glEnableVertexAttribArray(OpenGL::Attribute::TEXCOORD); glVertexAttribPointer(OpenGL::Attribute::TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, coord); #else const GLEnable<GL_TEXTURE_2D> scope; OpenGL::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(2, GL_FLOAT, 0, coord); #endif glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); #ifdef USE_GLSL glDisableVertexAttribArray(OpenGL::Attribute::TEXCOORD); OpenGL::solid_shader->Use(); #else glDisableClientState(GL_TEXTURE_COORD_ARRAY); #endif }
string QMerge::toString() { string r = ""; r = "MERGE "; Projection* p = getProjection(); r += p->toString(); return r; }
bool ProjectionSerializerV1::store(IlwisObject *obj, const IOOptions &options) { if (!VersionedSerializer::store(obj, options)) return false; Projection *proj = static_cast<Projection *>(obj); QString proj4Def = proj->toProj4(); _stream << proj4Def; _stream << proj->authority(); return true; }
/// Returns true if we are accessing different fields. static bool areProjectionsToDifferentFields(const Projection &P1, const Projection &P2) { // If operands have the same type and we are accessing different fields, // returns true. Operand's type is not saved in Projection. Instead we check // Decl's context. if (!P1.isNominalKind() || !P2.isNominalKind()) return false; return P1.getDecl()->getDeclContext() == P2.getDecl()->getDeclContext() && P1 != P2; }
static void TestGeoScreenCouple(const Projection prj, const GeoPoint geo, long x, long y) { RasterPoint tmp_pt = prj.GeoToScreen(geo); ok1(tmp_pt.x == x); ok1(tmp_pt.y == y); GeoPoint tmp_geo = prj.ScreenToGeo(x, y); ok1(equals(tmp_geo.latitude, geo.latitude)); ok1(equals(tmp_geo.longitude, geo.longitude)); }
bool FileProjections::isProjectionExist(unsigned nodeId) const { if (isMemoryUsed()) { return Projections::isProjectionExist(nodeId); } Projection* pr = nullptr; if (loadedProjection && loadedProjection->getId() == nodeId) pr = loadedProjection; else pr = Projections::getProjection(nodeId); return !pr ? false : pr->fileExist(); }
BOOL MainWindow::StartReconstruction() { // read in variables from GUI WCHAR szText[8]; INT nxy, nz; FLOAT res, cutoff; filter_type filter; SendMessage(m_hDimensions[0],WM_GETTEXT,64,(LPARAM)szText); nxy = _wtoi(szText); SendMessage(m_hDimensions[1],WM_GETTEXT,64,(LPARAM)szText); nz = _wtoi(szText); SendMessage(m_hDimensions[2],WM_GETTEXT,64,(LPARAM)szText); res = _wtof(szText); filter = (filter_type)SendMessage(m_hFilter,CB_GETCURSEL,NULL,NULL); cutoff = SendMessage(m_hCutoff,TBM_GETPOS,NULL,NULL)/10.0; m_Recon = new Reconstruction(nz, nxy, nxy, res, m_Proj); m_Recon->SetHWND(m_hwnd); m_Proj->CreateFilter(filter,cutoff); m_thrRecon = _beginthreadex(NULL, 0, Reconstruction::ReconThread, m_Recon, 0, NULL); if(!m_thrRecon) return FALSE; return TRUE; }
//Simplistic test. TEST(MAIN, Projection){ Projection a; float PI_VAL = 3.14159; EXPECT_EQ( 1, a.zoom); EXPECT_EQ( 0, a.zoom_x); EXPECT_EQ( 0, a.zoom_y); EXPECT_TRUE(a.ex.x == 1.0) << a.ex.x; a.Reset(); EXPECT_EQ( 1.0, a.X().x); a.Rotate( PI_VAL, PI_VAL); EXPECT_EQ( -1.0, a.X().x); };
void MapPainterSVG::DrawGround(const Projection& projection, const MapParameter& parameter, const FillStyle& style) { stream << " <rect x=\"" << 0 << "\" y=\"" << 0 << "\" width=\"" << projection.GetWidth() << "\" height=\"" << projection.GetHeight() << "\"" << std::endl; stream << " fill=\"" << GetColorValue(style.GetFillColor()) << "\"" << "/>" << std::endl; }
void MapCanvas::project(const Projection &projection, const SearchPointVector &points, RasterPoint *screen) { for (auto it = points.begin(); it != points.end(); ++it) *screen++ = projection.GeoToScreen(it->get_location()); }
// *************************************************************************** bool AlbersConicProjection::operator==( const Projection& p ) const throw() { const AlbersConicProjection* pRHS = NULL; try { // Check to see if the projection passed in is Albers Conic if ( ALBERS == p.getProjectionSystem() ) { pRHS = dynamic_cast<const AlbersConicProjection*>(&p); if ( NULL != pRHS ) { if ( d_projParams[2] == pRHS->getFirstStandardParallel() && d_projParams[3] == pRHS->getSecondStandardParallel() ) { return ConicProjection::operator==( *pRHS ); } } } return false; } catch (...) { return false; } }
void _appendHelper( BSONObjBuilder& result , const BSONObj& doc , bool found , const BSONObj& fields ) { if ( ! found ) { result.appendNull( "value" ); return; } if ( fields.isEmpty() ) { result.append( "value" , doc ); return; } Projection p; p.init( fields ); result.append( "value" , p.transform( doc ) ); }
void ROI::draw (const Projection& projection, bool is_3D, int, int) { if (is_3D) return; if (!is_3D) { // set up OpenGL environment: gl::Enable (gl::BLEND); gl::Disable (gl::DEPTH_TEST); gl::DepthMask (gl::FALSE_); gl::ColorMask (gl::TRUE_, gl::TRUE_, gl::TRUE_, gl::TRUE_); gl::BlendFunc (gl::SRC_ALPHA, gl::ONE_MINUS_SRC_ALPHA); gl::BlendEquation (gl::FUNC_ADD); } for (int i = 0; i < list_model->rowCount(); ++i) { if (list_model->items[i]->show && !hide_all_button->isChecked()) { ROI_Item* roi = dynamic_cast<ROI_Item*>(list_model->items[i].get()); //if (is_3D) //window.get_current_mode()->overlays_for_3D.push_back (image); //else roi->render (shader, projection, projection.depth_of (window().focus())); } } if (!is_3D) { // restore OpenGL environment: gl::Disable (gl::BLEND); gl::Enable (gl::DEPTH_TEST); gl::DepthMask (gl::TRUE_); } }
// *************************************************************************** bool StatePlaneProjection::operator==( const Projection& p ) const throw() { const StatePlaneProjection* pRHS = NULL; try { // Check to see if the projection passed in is UTM if ( SPCS == p.getProjectionSystem() ) { pRHS = dynamic_cast<const StatePlaneProjection*>(&p); if ( NULL != pRHS ) { if ( d_zone == pRHS->getZone() ) { return Projection::operator==(p); } } } return false; } catch (...) { return false; } }
void MapCanvas::Project(const Projection &projection, const SearchPointVector &points, BulkPixelPoint *screen) { for (auto it = points.begin(); it != points.end(); ++it) *screen++ = projection.GeoToScreen(it->GetLocation()); }
void MapPainterOpenGL::DrawGround(const Projection& projection, const MapParameter& /*parameter*/, const FillStyle& style) { glColor4d(style.GetFillColor().GetR(), style.GetFillColor().GetG(), style.GetFillColor().GetB(), style.GetFillColor().GetA()); glBegin(GL_QUADS); glVertex3d(0,projection.GetHeight(),0.0); // Top Left glVertex3d(projection.GetWidth(),projection.GetHeight(),0.0); // Top Right glVertex3d(projection.GetWidth(),0.0,0.0); // Bottom Right glVertex3d(0,0,0.0); // Bottom Left glEnd(); }
void TransPolygon::TransformWay(const Projection& projection, bool optimize, const std::vector<Point>& nodes) { if (nodes.empty()) { length=0; return; } length=nodes.size(); if (pointsSize<length) { delete [] points; points=new TransPoint[length]; pointsSize=length; } if (optimize) { InitializeDraw(); TransformGeoToPixel(projection, nodes); DropSimilarPoints(); DropRedundantPoints(); length=0; start=nodes.size(); end=0; // Calculate start & end for (size_t i=0; i<nodes.size(); i++) { if (points[i].draw) { length++; if (i<start) { start=i; } end=i; } } } else { start=0; end=nodes.size()-1; length=nodes.size(); for (size_t i=0; i<nodes.size(); i++) { points[i].draw=true; projection.GeoToPixel(nodes[i].lon, nodes[i].lat, points[i].x, points[i].y); } } }
IlwisObject *InternalIlwisObjectFactory::createProjection(const Resource& resource, const IOOptions &options) const { QString query; QString code = resource.code(); Projection *proj = 0; if ( code == sUNDEF){ // meant for new projections which will be initialized later (e.g by the streaming connector) proj = createFromResource<Projection>(resource, options); } else if ( code != "") { InternalDatabaseConnection db; query = QString("Select * from projection where code = '%1'").arg(code); if ( db.exec(query)) { if (db.next()) { QSqlRecord rec = db.record(); const ProjectionFactory *factory = kernel()->factory<ProjectionFactory>("ProjectionFactory",resource); if ( factory) { ProjectionImplementation *projimpl = 0; if ( options.contains("proj4")) projimpl = static_cast<ProjectionImplementation *>(factory->create(resource.code(), options["proj4"].toString())); else projimpl = static_cast<ProjectionImplementation *>(factory->create(resource)); if (!projimpl) { kernel()->issues()->log(TR(ERR_COULDNT_CREATE_OBJECT_FOR_2).arg("projection", resource.name())); return 0; } proj = createFromResource<Projection>(resource, options); proj->setImplementation(projimpl); proj->fromInternal(rec); proj->setAuthority(rec.field("authority").value().toString()); proj->setWkt(rec.field("wkt").value().toString()); } else { kernel()->issues()->log(TR(ERR_COULDNT_CREATE_OBJECT_FOR_2).arg("ProjectionFactory",resource.name())); } } else { kernel()->issues()->log(TR(ERR_FIND_SYSTEM_OBJECT_1).arg(code)); } } else{ kernel()->issues()->logSql(db.lastError()); } } else { kernel()->issues()->log(TR(ERR_MISSING_CODE_FOR_SYSTEM_OBJECT)); } return proj; }
void MapPainterAgg::SetOutlineFont(const Projection& projection, const MapParameter& parameter, double size) { if (!fontEngine->load_font(parameter.GetFontName().c_str(), 0, agg::glyph_ren_outline)) { std::cout << "Cannot load font '" << parameter.GetFontName() << "'" << std::endl; return; } //fontEngine->resolution(72); fontEngine->width(size*projection.ConvertWidthToPixel(parameter.GetFontSize())); fontEngine->height(size*projection.ConvertWidthToPixel(parameter.GetFontSize())); fontEngine->hinting(true); fontEngine->flip_y(true); }
void TransPolygon::TransformGeoToPixel(const Projection& projection, const std::vector<Point>& nodes) { for (size_t i=0; i<length; i++) { if (points[i].draw) { projection.GeoToPixel(nodes[i].lon,nodes[i].lat, points[i].x,points[i].y); } } }
static void _appendHelper(BSONObjBuilder& result, const BSONObj& doc, bool found, const BSONObj& fields, const MatchExpressionParser::WhereCallback& whereCallback) { if ( ! found ) { result.appendNull( "value" ); return; } if ( fields.isEmpty() ) { result.append( "value" , doc ); return; } Projection p; p.init(fields, whereCallback); result.append( "value" , p.transform( doc ) ); }
bool ProjectionSerializerV1::loadMetaData(IlwisObject *obj, const IOOptions &options) { if (!VersionedSerializer::loadMetaData(obj, options)) return false; const ProjectionFactory *factory = kernel()->factory<ProjectionFactory>("ProjectionFactory","proj4"); if ( !factory) return false; Projection *proj = static_cast<Projection *>(obj); QString proj4Def; _stream >> proj4Def; ProjectionImplementation *impl = factory->create(proj4Def) ; if (!impl) return false; proj->setImplementation(impl); QString authority; _stream >> authority; proj->setAuthority(authority); return true; }
void Frustum::Split(const Matrix44f &viewMatrix, const Projection &proj, const float parts[], size_t nparts, Projection projout[], Frustum frusout[], float epsilon) { proj.Split(parts, nparts, projout, epsilon); for (size_t i=0; i < nparts; ++i) { frusout[i] = Frustum(viewMatrix, projout[i]); } }