QgsDwgImportDialog::QgsDwgImportDialog( QWidget *parent, Qt::WindowFlags f ) : QDialog( parent, f ) { setupUi( this ); QSettings s; leDatabase->setText( s.value( "/DwgImport/lastDatabase", "" ).toString() ); cbExpandInserts->setChecked( s.value( "/DwgImport/lastExpandInserts", true ).toBool() ); cbMergeLayers->setChecked( s.value( "/DwgImport/lastMergeLayers", false ).toBool() ); cbUseCurves->setChecked( s.value( "/DwgImport/lastUseCurves", true ).toBool() ); #if !defined(GDAL_COMPUTE_VERSION) || GDAL_VERSION_NUM < GDAL_COMPUTE_VERSION(2,0,0) cbUseCurves->setChecked( false ); cbUseCurves->setHidden( true ); #endif leDrawing->setReadOnly( true ); pbImportDrawing->setHidden( true ); lblMessage->setHidden( true ); int crsid = s.value( "/DwgImport/lastCrs", QString::number( QgisApp::instance()->mapCanvas()->mapSettings().destinationCrs().srsid() ) ).toInt(); QgsCoordinateReferenceSystem crs( crsid, QgsCoordinateReferenceSystem::InternalCrsId ); mCrsSelector->setCrs( crs ); mCrsSelector->setLayerCrs( crs ); mCrsSelector->dialog()->setMessage( tr( "Select the coordinate reference system for the dxf file. " "The data points will be transformed from the layer coordinate reference system." ) ); on_pbLoadDatabase_clicked(); updateUI(); restoreGeometry( s.value( "/Windows/DwgImport/geometry" ).toByteArray() ); }
QgsDwgImportDialog::QgsDwgImportDialog( QWidget *parent, Qt::WindowFlags f ) : QDialog( parent, f ) { setupUi( this ); connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsDwgImportDialog::showHelp ); QgsSettings s; leDatabase->setText( s.value( QStringLiteral( "/DwgImport/lastDatabase" ), "" ).toString() ); cbExpandInserts->setChecked( s.value( QStringLiteral( "/DwgImport/lastExpandInserts" ), true ).toBool() ); cbMergeLayers->setChecked( s.value( QStringLiteral( "/DwgImport/lastMergeLayers" ), false ).toBool() ); cbUseCurves->setChecked( s.value( QStringLiteral( "/DwgImport/lastUseCurves" ), true ).toBool() ); leDrawing->setReadOnly( true ); pbImportDrawing->setHidden( true ); lblMessage->setHidden( true ); int crsid = s.value( QStringLiteral( "/DwgImport/lastCrs" ), QString::number( QgsProject::instance()->crs().srsid() ) ).toInt(); QgsCoordinateReferenceSystem crs( crsid, QgsCoordinateReferenceSystem::InternalCrsId ); mCrsSelector->setCrs( crs ); mCrsSelector->setLayerCrs( crs ); mCrsSelector->dialog()->setMessage( tr( "Select the coordinate reference system for the dxf file. " "The data points will be transformed from the layer coordinate reference system." ) ); on_pbLoadDatabase_clicked(); updateUI(); restoreGeometry( s.value( QStringLiteral( "/Windows/DwgImport/geometry" ) ).toByteArray() ); }
float QgsTerrainGenerator::rootChunkError( const Qgs3DMapSettings &map ) const { QgsRectangle te = extent(); QgsCoordinateTransform terrainToMapTransform( crs(), map.crs() ); te = terrainToMapTransform.transformBoundingBox( te ); // use texel size as the error return te.width() / map.mapTileResolution(); }
void CObjInfo::fillInfo(const mapView_t *, ofiItem_t *info) /////////////////////////////////////////////////////////// { QString str; setWindowTitle(tr("Object information : ") + info->title); str += "<table>\n"; for (int i = 0; i < info->tTextItem.count(); i++) { ofiTextItem_t *item = &info->tTextItem[i]; str += "<tr>\n"; str += "<td>\n"; if (item->bBold) str += "<b>"; if (item->bIsTitle) str += "<u>"; str += item->label; if (item->bIsTitle) str += "</u>"; str += "</td>\n"; if (!item->bIsTitle && !item->value.isEmpty()) { str += "<td>\n"; str += " : "; str += "</td>\n"; str += "<td>\n"; str += item->value; str += "</td>\n"; } if (item->bBold) str += ("</b>"); str += "</tr>\n"; } str += "</table>\n"; ui->textBrowser1->setHtml(str); QTextCursor crs(ui->textBrowser1->textCursor()); crs.setPosition(0); ui->textBrowser1->setTextCursor(crs); }
static void BPointHandler(X6502 *X, int type, unsigned int A) { if(multistep) return; /* To handle instructions that can cause multiple breakpoints per instruction. */ if(!dwin) return; /* Window is closed, don't do breakpoints. */ multistep=1; instep=0; crs(dwin); MultiCB(X); }
QgsAABB QgsTerrainGenerator::rootChunkBbox( const Qgs3DMapSettings &map ) const { QgsRectangle te = extent(); QgsCoordinateTransform terrainToMapTransform( crs(), map.crs() ); te = terrainToMapTransform.transformBoundingBox( te ); float hMin, hMax; rootChunkHeightRange( hMin, hMax ); return QgsAABB( te.xMinimum() - map.originX(), hMin * map.terrainVerticalScale(), -te.yMaximum() + map.originY(), te.xMaximum() - map.originX(), hMax * map.terrainVerticalScale(), -te.yMinimum() + map.originY() ); }
QgsFeatureList QgsClipboard::transformedCopyOf( QgsCoordinateReferenceSystem destCRS ) { QgsFeatureList featureList = copyOf(); QgsCoordinateTransform ct( crs(), destCRS ); QgsDebugMsg( "transforming clipboard." ); for ( QgsFeatureList::iterator iter = featureList.begin(); iter != featureList.end(); ++iter ) { iter->geometry()->transform( ct ); } return featureList; }
void QgsProjectionSelectionTreeWidget::updateBoundsPreview() { QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem(); if ( !lvi || lvi->text( QgisCrsIdColumn ).isEmpty() ) return; QgsCoordinateReferenceSystem currentCrs = crs(); if ( !currentCrs.isValid() ) return; QgsRectangle rect = currentCrs.bounds(); if ( !qgsDoubleNear( rect.area(), 0.0 ) ) { QgsGeometry geom; if ( rect.xMinimum() > rect.xMaximum() ) { QgsRectangle rect1 = QgsRectangle( -180, rect.yMinimum(), rect.xMaximum(), rect.yMaximum() ); QgsRectangle rect2 = QgsRectangle( rect.xMinimum(), rect.yMinimum(), 180, rect.yMaximum() ); geom = QgsGeometry::fromRect( rect1 ); geom.addPart( QgsGeometry::fromRect( rect2 ) ); } else { geom = QgsGeometry::fromRect( rect ); } mPreviewBand->setToGeometry( geom, nullptr ); mPreviewBand->setColor( QColor( 255, 0, 0, 65 ) ); QgsRectangle extent = geom.boundingBox(); extent.scale( 1.1 ); mAreaCanvas->setExtent( extent ); mAreaCanvas->refresh(); mPreviewBand->show(); QString extentString = tr( "Extent: %1, %2, %3, %4" ) .arg( rect.xMinimum(), 0, 'f', 2 ) .arg( rect.yMinimum(), 0, 'f', 2 ) .arg( rect.xMaximum(), 0, 'f', 2 ) .arg( rect.yMaximum(), 0, 'f', 2 ); QString proj4String = tr( "Proj4: %1" ).arg( selectedProj4String() ); teProjection->setText( extentString + "\n" + proj4String ); } else { mPreviewBand->hide(); mAreaCanvas->zoomToFullExtent(); QString extentString = tr( "Extent: Extent not known" ); QString proj4String = tr( "Proj4: %1" ).arg( selectedProj4String() ); teProjection->setText( extentString + "\n" + proj4String ); } }
QgsProjectionSelectionTreeWidget::~QgsProjectionSelectionTreeWidget() { qDeleteAll( mLayers ); delete mPreviewBand; delete mPreviewBand2; delete mVertexMarker; if ( !mPushProjectionToFront ) { return; } // Push current projection to front, only if set long crsId = selectedCrsId(); if ( crsId == 0 ) return; // Save persistent list of projects mRecentProjections.removeAll( QString::number( crsId ) ); mRecentProjections.prepend( QString::number( crsId ) ); // Prune size of list while ( mRecentProjections.size() > 8 ) { mRecentProjections.removeLast(); } // Save to file *** Should be removed sometims in the future *** QgsSettings settings; settings.setValue( QStringLiteral( "/UI/recentProjections" ), mRecentProjections ); // Convert to EPSG and proj4, and save those values also QStringList projectionsProj4; QStringList projectionsAuthId; for ( int i = 0; i < mRecentProjections.size(); i++ ) { // Create a crs from the crsId QgsCoordinateReferenceSystem crs( mRecentProjections.at( i ).toLong(), QgsCoordinateReferenceSystem::InternalCrsId ); if ( ! crs.isValid() ) { // No? Skip this entry continue; } projectionsProj4 << crs.toProj4(); projectionsAuthId << crs.authid(); } settings.setValue( QStringLiteral( "/UI/recentProjectionsProj4" ), projectionsProj4 ); settings.setValue( QStringLiteral( "/UI/recentProjectionsAuthId" ), projectionsAuthId ); }
QgsDwgImportDialog::QgsDwgImportDialog( QWidget *parent, Qt::WindowFlags f ) : QDialog( parent, f ) { setupUi( this ); mDatabaseFileWidget->setStorageMode( QgsFileWidget::SaveFile ); connect( buttonBox, &QDialogButtonBox::accepted, this, &QgsDwgImportDialog::buttonBox_accepted ); connect( mDatabaseFileWidget, &QgsFileWidget::fileChanged, this, &QgsDwgImportDialog::mDatabaseFileWidget_textChanged ); connect( pbBrowseDrawing, &QPushButton::clicked, this, &QgsDwgImportDialog::pbBrowseDrawing_clicked ); connect( pbImportDrawing, &QPushButton::clicked, this, &QgsDwgImportDialog::pbImportDrawing_clicked ); connect( pbLoadDatabase, &QPushButton::clicked, this, &QgsDwgImportDialog::pbLoadDatabase_clicked ); connect( pbSelectAll, &QPushButton::clicked, this, &QgsDwgImportDialog::pbSelectAll_clicked ); connect( pbDeselectAll, &QPushButton::clicked, this, &QgsDwgImportDialog::pbDeselectAll_clicked ); connect( leLayerGroup, &QLineEdit::textChanged, this, &QgsDwgImportDialog::leLayerGroup_textChanged ); connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsDwgImportDialog::showHelp ); QgsSettings s; cbExpandInserts->setChecked( s.value( QStringLiteral( "/DwgImport/lastExpandInserts" ), true ).toBool() ); cbMergeLayers->setChecked( s.value( QStringLiteral( "/DwgImport/lastMergeLayers" ), false ).toBool() ); cbUseCurves->setChecked( s.value( QStringLiteral( "/DwgImport/lastUseCurves" ), true ).toBool() ); mDatabaseFileWidget->setDefaultRoot( s.value( QStringLiteral( "/DwgImport/lastDirDatabase" ), QDir::homePath() ).toString() ); leDrawing->setReadOnly( true ); pbImportDrawing->setHidden( true ); lblMessage->setHidden( true ); int crsid = s.value( QStringLiteral( "/DwgImport/lastCrs" ), QString::number( QgsProject::instance()->crs().srsid() ) ).toInt(); QgsCoordinateReferenceSystem crs( crsid, QgsCoordinateReferenceSystem::InternalCrsId ); mCrsSelector->setCrs( crs ); mCrsSelector->setLayerCrs( crs ); mCrsSelector->setMessage( tr( "Select the coordinate reference system for the dxf file. " "The data points will be transformed from the layer coordinate reference system." ) ); pbLoadDatabase_clicked(); updateUI(); restoreGeometry( s.value( QStringLiteral( "/Windows/DwgImport/geometry" ) ).toByteArray() ); }
Rcpp::List get_crs(OGRSpatialReference *ref) { Rcpp::List crs(2); if (ref == NULL) { crs(0) = NA_INTEGER; crs(1) = Rcpp::CharacterVector::create(NA_STRING); } else { const char *cp; if (ref->AutoIdentifyEPSG() == OGRERR_NONE && (cp = ref->GetAuthorityCode(NULL)) != NULL) crs(0) = atoi(cp); else crs(0) = NA_INTEGER; crs(1) = p4s_from_spatial_reference(ref); } Rcpp::CharacterVector nms(2); nms(0) = "epsg"; nms(1) = "proj4string"; crs.attr("names") = nms; crs.attr("class") = "crs"; return crs; }
void controlCamera() { // Set the camera GLfloat up[3] = {0.0f, 1.0f, 0.0f}; if (keysDown & mKey) { up[0] = sin(controlled->angle); up[1] = 0.0f; up[2] = -cos(controlled->angle); } float height = -1.0f; if (keysDown & mKey) height = -150.0f; GLfloat f[3] = {sin(controlled->angle), 0.0f, -cos(controlled->angle)}; if (keysDown & mKey) { f[0] = 0.0f; f[1] = -1.0f; f[2] = 0.0f; } GLfloat fNor[3]; nor(f, fNor); GLfloat s[3]; crs(fNor, up, s); GLfloat sNor[3]; nor(s, sNor); GLfloat u[3]; crs(sNor, fNor, u); GLfloat camMat[4][4]; camMat[0][0] = s[0]; camMat[1][0] = s[1]; camMat[2][0] = s[2]; camMat[3][0] = 0.0f; camMat[0][1] = u[0]; camMat[1][1] = u[1]; camMat[2][1] = u[2]; camMat[3][1] = 0.0f; camMat[0][2] = -f[0]; camMat[1][2] = -f[1]; camMat[2][2] = -f[2]; camMat[3][2] = 0.0f; camMat[0][3] = 0.0f; camMat[1][3] = 0.0f; camMat[2][3] = 0.0f; camMat[3][3] = 1.0f; glLoadIdentity(); glMultMatrixf(camMat[0]); glTranslated(-controlled->pos.x*CREATURE_WIDTH*2, height, -controlled->pos.y*CREATURE_HEIGHT*2); //gluLookAt( x, 1.0f, z, // x+lx, 1.0f, z+lz, // 0.0f, 1.0f, 0.0f); }
void CObjInfo::init(CMapView *map, const mapView_t *view, const mapObj_t *obj) ////////////////////////////////////////////////////////////////////////////// { CObjFillInfo info; m_map = map; ui->pushButton_3->setEnabled(false); ui->clb_slew->setEnabled(g_pTelePlugin && (g_pTelePlugin->getAttributes() & TPI_CAN_SLEW)); ui->clb_sync->setEnabled(g_pTelePlugin && (g_pTelePlugin->getAttributes() & TPI_CAN_SYNC)); ui->clb_tracking->setEnabled(obj->type == MO_PLANET || obj->type == MO_ASTER || obj->type == MO_COMET || obj->type == MO_SATELLITE); ui->cb_simbad->setDisabled(obj->type == MO_PLANET || obj->type == MO_ASTER || obj->type == MO_COMET || obj->type == MO_PLN_SAT || obj->type == MO_SATELLITE); ui->pushButton_2->setDisabled(obj->type == MO_PLANET || obj->type == MO_ASTER || obj->type == MO_COMET || obj->type == MO_PLN_SAT || obj->type == MO_SATELLITE); ui->pushButton_3->setEnabled(obj->type == MO_ASTER || obj->type == MO_COMET); info.fillInfo(view, obj, &m_infoItem); /// read note QString str = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/data/notes/" + m_infoItem.id + ".txt"; SkFile f(str); if (f.open(SkFile::ReadOnly | SkFile::Text)) { ui->textEdit->setPlainText(f.readAll()); f.close(); } QTextCursor crs(ui->textEdit->textCursor()); crs.movePosition(QTextCursor::End); ui->textEdit->setTextCursor(crs); ///////////// fillInfo(view, &m_infoItem); ui->textEdit->setFocus(); if (m_infoItem.type == MO_PLANET && m_infoItem.par1 != PT_EARTH_SHADOW) { m_pixmapWidget = new CPixmapWidget(); ui->gridLayout_5->addWidget(m_pixmapWidget); m_pixmapWidget->setPixmap(getPlanetPixmap(m_pixmapWidget->width(), m_pixmapWidget->height())); CXMLSimpleMapParser parser; parser.begin(readAllFile("../data/planets/" + CAstro::getFileName(m_infoItem.par1) + ".xml")); QString str = "<table>\n"; str += addPhysicalInfo(&parser, "Equator_radius", tr("Equator radius")); str += addPhysicalInfo(&parser, "Semi_major_axis", tr("Semi-major axis")); str += addPhysicalInfo(&parser, "Eccentricity", tr("Eccentricity")); str += addPhysicalInfo(&parser, "Mass", tr("Mass")); str += addPhysicalInfo(&parser, "Rotation_period", tr("Rotation period")); str += addPhysicalInfo(&parser, "Escape_velocity", tr("Escape velocity")); str += "</table>\n"; ui->textBrowser_2->setHtml(str); } else { ui->tabWidget->blockSignals(true); ui->tabWidget->removeTab(1); ui->tabWidget->removeTab(1); ui->tabWidget->blockSignals(false); } }
void CgiResponseHandler::SendResponse(MgHttpResponse* response) { MG_TRY() Ptr<MgHttpResult> result = response->GetResult(); STATUS status = result->GetStatusCode(); if (status != 200) { STRING statusMessage = result->GetHttpStatusMessage(); if (statusMessage == MapAgentStrings::FailedAuth1 || statusMessage == MapAgentStrings::FailedAuth2) { RequestAuth(); } else { //TODO: Use a resource for the HTML error message STRING shortError = result->GetErrorMessage(); STRING longError = result->GetDetailedErrorMessage(); printf(MapAgentStrings::StatusHeader, status, MG_WCHAR_TO_CHAR(statusMessage)); printf(MapAgentStrings::ContentTypeHeader, MapAgentStrings::TextHtml, ""); printf("\r\n" "<html>\n<head>\n" "<title>%s</title>\n" "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n" "</head>\n" "<body>\n<h2>%s</h2>\n%s\n</body>\n</html>\n", MG_WCHAR_TO_CHAR(statusMessage), MG_WCHAR_TO_CHAR(shortError), MG_WCHAR_TO_CHAR(longError)); DumpMessage(MG_WCHAR_TO_CHAR(longError)); } } else { DumpMessage(MapAgentStrings::StatusOkHeader); // Status was ok. Send the real result back. STRING contentType = result->GetResultContentType(); STRING stringVal; printf(MapAgentStrings::StatusOkHeader); if (contentType.length() > 0) { // If we are returning text, state that it is utf-8. string charSet = ""; if (contentType.find(L"text") != contentType.npos) //NOXLATE { charSet = MapAgentStrings::Utf8Text; } printf(MapAgentStrings::ContentTypeHeader, MG_WCHAR_TO_CHAR(contentType), charSet.c_str()); } else { printf(MapAgentStrings::ContentTypeHeader, MapAgentStrings::TextPlain, MapAgentStrings::Utf8Text); } Ptr<MgByteReader> outputReader; Ptr<MgDisposable> resultObj = result->GetResultObject(); MgDisposable* pResultObj = (MgDisposable*)resultObj; if (NULL != dynamic_cast<MgByteReader*>(pResultObj)) { outputReader = (MgByteReader*) SAFE_ADDREF(pResultObj); } else if (NULL != dynamic_cast<MgStringCollection*>(pResultObj)) { outputReader = ((MgStringCollection*)pResultObj)->ToXml(); } else if (NULL != dynamic_cast<MgSpatialContextReader*>(pResultObj)) { outputReader = ((MgSpatialContextReader*)pResultObj)->ToXml(); } else if (NULL != dynamic_cast<MgLongTransactionReader*>(pResultObj)) { outputReader = ((MgLongTransactionReader*)pResultObj)->ToXml(); } else if (NULL != dynamic_cast<MgHttpPrimitiveValue*>(pResultObj)) { stringVal = ((MgHttpPrimitiveValue*)pResultObj)->ToString(); } if (stringVal.length() > 0) { string utf8 = MG_WCHAR_TO_CHAR(stringVal); printf(MapAgentStrings::ContentLengthHeader, utf8.length()); printf("\r\n%s",utf8.c_str()); } else if (outputReader != NULL) { Ptr<MgHttpHeader> respHeader = response->GetHeader(); //Check for chunking hint if (respHeader->GetHeaderValue(MgHttpResourceStrings::hrhnTransfer_Encoding) == MgHttpResourceStrings::hrhnChunked) { CgiReaderStreamer crs(outputReader); crs.StreamResult(); } else { INT64 outLen = outputReader->GetLength(); printf(MapAgentStrings::ContentLengthHeader,(INT32)outLen); printf("\r\n"); unsigned char buf[4096]; int nBytes = outputReader->Read(buf,4096); while (nBytes > 0) { fwrite(buf, 1, nBytes, stdout); nBytes = outputReader->Read(buf,4096); } } } else { printf(MapAgentStrings::ContentLengthHeader, 0); printf("\r\n"); } } MG_CATCH_AND_THROW(L"CgiResponseHandler.SendResponse"); }
static BOOL CALLBACK DebugCon(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { int32 scrollindex=0,ced=0; int type; DSMFix(uMsg); switch(uMsg) { case WM_INITDIALOG: crs(hwndDlg); DoVecties(hwndDlg); FCEUI_SetCPUCallback(cpucb); RebuildBPointList(hwndDlg); break; case WM_VSCROLL: if(0!=instep) break; switch((int)LOWORD(wParam)) { case SB_TOP: scrollindex=-32768; ced=1; break; case SB_BOTTOM: scrollindex=32767; ced=1; break; case SB_LINEUP: scrollindex=GetScrollPos(GetDlgItem(hwndDlg,101),SB_CTL); if(scrollindex>-32768) { scrollindex--; ced=1; } break; case SB_PAGEUP: scrollindex=GetScrollPos(GetDlgItem(hwndDlg,101),SB_CTL); scrollindex-=27; if(scrollindex<-32768) scrollindex=-32768; ced=1; break; case SB_LINEDOWN: scrollindex=GetScrollPos(GetDlgItem(hwndDlg,101),SB_CTL); if(scrollindex<32767) { scrollindex++; ced=1; } break; case SB_PAGEDOWN: scrollindex=GetScrollPos(GetDlgItem(hwndDlg,101),SB_CTL); scrollindex+=27; if(scrollindex>32767) { scrollindex=32767; } ced=1; break; case SB_THUMBPOSITION: case SB_THUMBTRACK: scrollindex=(int16)(wParam>>16); ced=1; break; } if(ced) { SendDlgItemMessage(hwndDlg,101,SBM_SETPOS,scrollindex,1); Disyou(scrollindex+32768); } break; case WM_CLOSE: case WM_QUIT: goto gornk; case WM_COMMAND: switch(HIWORD(wParam)) { case LBN_DBLCLK: // if(0==instep) // { // Xsave->PC=asavers[SendDlgItemMessage(hwndDlg,100,LB_GETCURSEL,0,0)]; // RRegs(Xsave); // Disyou(Xsave->PC); // } // break; if((0==instep)&&(LOWORD(wParam)==0x64)) { uint16 A1, A2; type = BPOINT_READ|BPOINT_PC; A1=A2=asavers[SendDlgItemMessage(hwndDlg,100,LB_GETCURSEL,0,0)]; FCEUI_AddBreakPoint(type,A1,A2,BPointHandler); hWndCallB=hwndDlg; /* Hacky hacky. */ RBPCallBack(type,A1,A2,0); } break; case EN_KILLFOCUS: { char TempArray[64]; int id=LOWORD(wParam); GetDlgItemText(hwndDlg,id,TempArray,64); if(0==instep) { int tscroll=32768+SendDlgItemMessage(hwndDlg,101,SBM_GETPOS,0,0); switch(id) { case 200: if(Xsave->PC!=StrToU16(TempArray)) { Xsave->PC=StrToU16(TempArray); Disyou(Xsave->PC); RRegs(Xsave); } break; case 201:Xsave->S=StrToU8(TempArray); RRegs(Xsave); Disyou(tscroll); break; case 202:Xsave->P&=0x30; Xsave->P|=StrToU8(TempArray)&~0x30; RFlags(Xsave); Disyou(tscroll); break; case 210:Xsave->A=StrToU8(TempArray); RRegs(Xsave); Disyou(tscroll); break; case 211:Xsave->X=StrToU8(TempArray); RRegs(Xsave); Disyou(tscroll); break; case 212:Xsave->Y=StrToU8(TempArray); RRegs(Xsave); Disyou(tscroll); break; } } } break; case BN_CLICKED: if(LOWORD(wParam)>=400 && LOWORD(wParam)<=407) { if(0==instep) { Xsave->P^=1<<(LOWORD(wParam)&7); RFlags(Xsave); } } else switch(LOWORD(wParam)) { case 300: instep=1; crs(hwndDlg); if((PPUViewer) && (scanline == PPUViewScanline)) UpdatePPUView(1); break; case 301: instep=-1; crs(hwndDlg); break; case 302:FCEUI_NMI();break; case 303:FCEUI_IRQ();break; case 310:FCEUI_ResetNES(); if(instep>=0) instep=1; crs(hwndDlg); break; case 311:DoMemmo(hwndDlg);break; case 540: { LONG t; t=SendDlgItemMessage(hwndDlg,510,LB_GETCURSEL,0,0); if(t!=LB_ERR) { FCEUI_DeleteBreakPoint(t); SendDlgItemMessage(hWndCallB,510,LB_DELETESTRING,t,(LPARAM)(LPSTR)0); } } break; case 541: { uint16 A1,A2; int type; FetchBPDef(hwndDlg, &A1, &A2, &type); FCEUI_AddBreakPoint(type, A1,A2,BPointHandler); hWndCallB=hwndDlg; /* Hacky hacky. */ RBPCallBack(type, A1,A2,0); } break; } break; } if(!(wParam>>16)) switch(wParam&0xFFFF) { case 1: gornk: instep=-1; FCEUI_SetCPUCallback(0); DestroyWindow(dwin); dwin=0; break; } } return 0; }
QgsDb2Provider::QgsDb2Provider( QString uri ) : QgsVectorDataProvider( uri ) , mNumberFeatures( 0 ) , mEnvironment( ENV_LUW ) , mWkbType( QgsWkbTypes::Unknown ) { QgsDebugMsg( "uri: " + uri ); QgsDataSourceUri anUri = QgsDataSourceUri( uri ); if ( !anUri.srid().isEmpty() ) mSRId = anUri.srid().toInt(); else mSRId = -1; if ( 0 != anUri.wkbType() ) { mWkbType = anUri.wkbType(); } QgsDebugMsg( QString( "mWkbType: %1" ).arg( mWkbType ) ); QgsDebugMsg( QString( "new mWkbType: %1" ).arg( anUri.wkbType() ) ); mValid = true; mSkipFailures = false; int dim; // Not used db2WkbTypeAndDimension( mWkbType, mGeometryColType, dim ); // Get DB2 geometry type name mFidColName = anUri.keyColumn().toUpper(); QgsDebugMsg( "mFidColName " + mFidColName ); mExtents = anUri.param( "extents" ); QgsDebugMsg( "mExtents " + mExtents ); mUseEstimatedMetadata = anUri.useEstimatedMetadata(); QgsDebugMsg( QString( "mUseEstimatedMetadata: '%1'" ).arg( mUseEstimatedMetadata ) ); mSqlWhereClause = anUri.sql(); QString errMsg; mDatabase = getDatabase( uri, errMsg ); mConnInfo = anUri.connectionInfo(); QgsCoordinateReferenceSystem layerCrs = crs(); QgsDebugMsg( "CRS: " + layerCrs.toWkt() ); if ( !errMsg.isEmpty() ) { setLastError( errMsg ); QgsDebugMsg( mLastError ); mValid = false; return; } // Create a query for default connection mQuery = QSqlQuery( mDatabase ); mSchemaName = anUri.schema(); mTableName = anUri.table().toUpper(); QStringList sl = mTableName.split( '.' ); if ( sl.length() == 2 ) // Never seems to be the case { mSchemaName = sl[0]; mTableName = sl[1]; } if ( mSchemaName.isEmpty() ) { mSchemaName = anUri.username().toUpper(); } QgsDebugMsg( "mSchemaName: '" + mSchemaName + "; mTableName: '" + mTableName ); if ( !anUri.geometryColumn().isEmpty() ) mGeometryColName = anUri.geometryColumn().toUpper(); loadFields(); updateStatistics(); if ( mGeometryColName.isEmpty() ) { // table contains no geometries mWkbType = QgsWkbTypes::NoGeometry; mSRId = 0; } //fill type names into sets mNativeTypes // integer types << QgsVectorDataProvider::NativeType( tr( "8 Bytes integer" ), "bigint", QVariant::Int ) << QgsVectorDataProvider::NativeType( tr( "4 Bytes integer" ), "integer", QVariant::Int ) << QgsVectorDataProvider::NativeType( tr( "2 Bytes integer" ), "smallint", QVariant::Int ) << QgsVectorDataProvider::NativeType( tr( "Decimal number (numeric)" ), "numeric", QVariant::Double, 1, 31, 0, 31 ) << QgsVectorDataProvider::NativeType( tr( "Decimal number (decimal)" ), "decimal", QVariant::Double, 1, 31, 0, 31 ) // floating point << QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), "real", QVariant::Double ) << QgsVectorDataProvider::NativeType( tr( "Decimal number (double)" ), "double", QVariant::Double ) // date/time types << QgsVectorDataProvider::NativeType( tr( "Date" ), "date", QVariant::Date, -1, -1, -1, -1 ) << QgsVectorDataProvider::NativeType( tr( "Time" ), "time", QVariant::Time, -1, -1, -1, -1 ) << QgsVectorDataProvider::NativeType( tr( "Date & Time" ), "datetime", QVariant::DateTime, -1, -1, -1, -1 ) // string types << QgsVectorDataProvider::NativeType( tr( "Text, fixed length (char)" ), "char", QVariant::String, 1, 254 ) << QgsVectorDataProvider::NativeType( tr( "Text, variable length (varchar)" ), "varchar", QVariant::String, 1, 32704 ) << QgsVectorDataProvider::NativeType( tr( "Text, variable length large object (clob)" ), "clob", QVariant::String, 1, 2147483647 ) //DBCLOB is for 1073741824 double-byte characters, data length should be the same as CLOB (2147483647)? << QgsVectorDataProvider::NativeType( tr( "Text, variable length large object (dbclob)" ), "dbclob", QVariant::String, 1, 1073741824 ) ; }
QgsCoordinateReferenceSystem QgsVectorDataProvider::sourceCrs() const { return crs(); }
void QgsDwgImportDialog::on_pbLoadDatabase_clicked() { if ( !QFileInfo::exists( leDatabase->text() ) ) return; CursorOverride waitCursor; bool lblVisible = false; std::unique_ptr<QgsVectorLayer> d( new QgsVectorLayer( QStringLiteral( "%1|layername=drawing" ).arg( leDatabase->text() ), QStringLiteral( "layers" ), QStringLiteral( "ogr" ), false ) ); if ( d && d->isValid() ) { int idxPath = d->fields().lookupField( QStringLiteral( "path" ) ); int idxLastModified = d->fields().lookupField( QStringLiteral( "lastmodified" ) ); int idxCrs = d->fields().lookupField( QStringLiteral( "crs" ) ); QgsFeature f; if ( d->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList() << idxPath << idxLastModified << idxCrs ) ).nextFeature( f ) ) { leDrawing->setText( f.attribute( idxPath ).toString() ); QgsCoordinateReferenceSystem crs( f.attribute( idxCrs ).toInt(), QgsCoordinateReferenceSystem::InternalCrsId ); mCrsSelector->setCrs( crs ); mCrsSelector->setLayerCrs( crs ); QFileInfo fi( leDrawing->text() ); if ( fi.exists() ) { if ( fi.lastModified() > f.attribute( idxLastModified ).toDateTime() ) { lblMessage->setText( tr( "Drawing file was meanwhile updated (%1 > %2)." ).arg( fi.lastModified().toString(), f.attribute( idxLastModified ).toDateTime().toString() ) ); lblVisible = true; } } else { lblMessage->setText( tr( "Drawing file unavailable." ) ); lblVisible = true; } } } lblMessage->setVisible( lblVisible ); std::unique_ptr<QgsVectorLayer> l( new QgsVectorLayer( QStringLiteral( "%1|layername=layers" ).arg( leDatabase->text() ), QStringLiteral( "layers" ), QStringLiteral( "ogr" ), false ) ); if ( l && l->isValid() ) { int idxName = l->fields().lookupField( QStringLiteral( "name" ) ); int idxColor = l->fields().lookupField( QStringLiteral( "ocolor" ) ); int idxFlags = l->fields().lookupField( QStringLiteral( "flags" ) ); QgsDebugMsg( QString( "idxName:%1 idxColor:%2 idxFlags:%3" ).arg( idxName ).arg( idxColor ).arg( idxFlags ) ); QgsFeatureIterator fit = l->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList() << idxName << idxColor << idxFlags ) ); QgsFeature f; mLayers->setRowCount( 0 ); while ( fit.nextFeature( f ) ) { int row = mLayers->rowCount(); mLayers->setRowCount( row + 1 ); QgsDebugMsg( QString( "name:%1 color:%2 flags:%3" ).arg( f.attribute( idxName ).toString() ).arg( f.attribute( idxColor ).toInt() ).arg( f.attribute( idxFlags ).toString(), 0, 16 ) ); QTableWidgetItem *item = nullptr; item = new QTableWidgetItem( f.attribute( idxName ).toString() ); item->setFlags( Qt::ItemIsUserCheckable | Qt::ItemIsEnabled ); item->setCheckState( Qt::Checked ); mLayers->setItem( row, 0, item ); item = new QTableWidgetItem(); item->setFlags( Qt::ItemIsUserCheckable | Qt::ItemIsEnabled ); item->setCheckState( ( f.attribute( idxColor ).toInt() >= 0 && ( f.attribute( idxFlags ).toInt() & 1 ) == 0 ) ? Qt::Checked : Qt::Unchecked ); mLayers->setItem( row, 1, item ); } mLayers->resizeColumnsToContents(); buttonBox->button( QDialogButtonBox::Ok )->setEnabled( mLayers->rowCount() > 0 && !leLayerGroup->text().isEmpty() ); } else { QgisApp::instance()->messageBar()->pushMessage( tr( "Could not open layer list" ), QgsMessageBar::CRITICAL, 4 ); } }
float Vector2::crs(Vector2 * val) { return crs(val->getX(), val->getY()); }
int POINT(int n_points, struct quadruple *points, struct point_3d skip_point) /* c interpolation check of z-values in given points c */ { double errmax, h, xx, yy, r2, hz, zz, ww, err, xmm, ymm, zmm, wmm, r, etar; int n1, mm, m, mmax, inside; errmax = .0; n1 = n_points + 1; if (!cv) { for (mm = 1; mm <= n_points; mm++) { h = b[n1]; for (m = 1; m <= n_points; m++) { xx = points[mm - 1].x - points[m - 1].x; yy = points[mm - 1].y - points[m - 1].y; zz = points[mm - 1].z - points[m - 1].z; r2 = yy * yy + xx * xx + zz * zz; r = sqrt(r2); etar = (fi * r) / 2.; h = h + b[m] * crs(etar); } hz = h + wmin; ww = points[mm - 1].w + wmin; err = hz - ww; xmm = (points[mm - 1].x * dnorm) + xmn + current_region.west; ymm = (points[mm - 1].y * dnorm) + ymn + current_region.south; zmm = (points[mm - 1].z * dnorm) / zmult + zmn / zmult + current_region.bottom; if ((xmm >= xmn + current_region.west) && (xmm <= xmx + current_region.west) && (ymm >= ymn + current_region.south) && (ymm <= ymx + current_region.south) && (zmm >= zmn / zmult + current_region.bottom) && (zmm <= zmx / zmult + current_region.bottom)) inside = 1; else inside = 0; if (devi != NULL && inside == 1) point_save(xmm, ymm, zmm, err); if (err < 0) { err = -err; } if (err >= errmax) { errmax = err; mmax = mm; } } ertot = amax1(errmax, ertot); if (errmax > ertre) { xmm = (points[mmax - 1].x * dnorm) + ((struct octdata *)(root->data))->x_orig; ymm = (points[mmax - 1].y * dnorm) + ((struct octdata *)(root->data))->y_orig; zmm = (points[mmax - 1].z * dnorm) + ((struct octdata *)(root->data))->z_orig; wmm = points[mmax - 1].w + wmin; /* printf (" max. error = %f at point i = %d \n", errmax, mmax); printf (" x(i) = %f y(i) = %f \n", xmm, ymm); printf (" z(i) = %f w(i) = %f \n", zmm, wmm); */ } } /* cv stuff */ if (cv) { h = b[n1]; /* check this if h=b[0] used in 2d should be applied here */ for (m = 1; m <= n_points; m++) { /* number of points is already 1 less (skip_point) */ xx = points[m - 1].x - skip_point.x; yy = points[m - 1].y - skip_point.y; zz = points[m - 1].z - skip_point.z; r2 = yy * yy + xx * xx + zz * zz; if (r2 != 0.) { r = sqrt(r2); etar = (fi * r) / 2.; h = h + b[m] * crs(etar); } } hz = h + wmin; ww = skip_point.w + wmin; err = hz - ww; xmm = (skip_point.x * dnorm) + xmn + current_region.west; ymm = (skip_point.y * dnorm) + ymn + current_region.south; zmm = (skip_point.z * dnorm) / zmult + zmn / zmult + current_region.bottom; if ((xmm >= xmn + current_region.west) && (xmm <= xmx + current_region.west) && (ymm >= ymn + current_region.south) && (ymm <= ymx + current_region.south) && (zmm >= zmn / zmult + current_region.bottom) && (zmm <= zmx / zmult + current_region.bottom)) inside = 1; else inside = 0; if (inside == 1) point_save(xmm, ymm, zmm, err); } /* cv */ return 1; }
int COGRR1(double x_or, double y_or, double z_or, int n_rows, int n_cols, int n_levs, int n_points, struct quadruple *points, struct point_3d skip_point) /*C C INTERPOLATION BY FUNCTIONAL METHOD : TPS + complete regul. c */ { int secpar_loop(); static double *w2 = NULL; static double *wz2 = NULL; static double *wz1 = NULL; double amaxa; double stepix, stepiy, stepiz, RO, xx, yy, zz, xg, yg, zg, xx2; double wm, dx, dy, dz, dxx, dyy, dxy, dxz, dyz, dzz, h, bmgd1, bmgd2, etar, zcon, r, ww, wz, r2, hcell, zzcell2, etarcell, rcell, wwcell, zzcell; double x_crs,x_crsd,x_crsdd,x_crsdr2; int n1, k1, k2, k, i1, l, l1, n4, n5, m, i; int NGST, LSIZE, ngstc, nszc, ngstr, nszr, ngstl, nszl; int POINT(); int ind, ind1; static int first_time_z = 1; off_t offset, offset1, offset2; int bmask = 1; static FCELL *cell = NULL; int cond1 = (gradient != NULL) || (aspect1 != NULL) || (aspect2 != NULL); int cond2 = (ncurv != NULL) || (gcurv != NULL) || (mcurv != NULL); #define CEULER .57721566 /* C c character*32 fncdsm c normalization c */ offset1 = nsizr * nsizc; stepix = ew_res / dnorm; stepiy = ns_res / dnorm; stepiz = tb_res / dnorm; if (!w2) { if (!(w2 = (double *)G_malloc(sizeof(double) * (KMAX2 + 1)))) { clean(); G_fatal_error(_("Not enough memory for %s"), "w2"); } } if (!wz2) { if (!(wz2 = (double *)G_malloc(sizeof(double) * (KMAX2 + 1)))) { clean(); G_fatal_error(_("Not enough memory for %s"), "wz2"); } } if (!wz1) { if (!(wz1 = (double *)G_malloc(sizeof(double) * (KMAX2 + 1)))) { clean(); G_fatal_error(_("Not enough memory for %s"), "wz1"); } } if (cell == NULL) cell = Rast_allocate_f_buf(); for (i = 1; i <= n_points; i++) { points[i - 1].x = (points[i - 1].x - x_or) / dnorm; points[i - 1].y = (points[i - 1].y - y_or) / dnorm; points[i - 1].z = (points[i - 1].z - z_or) / dnorm; } if (cv) { skip_point.x = (skip_point.x - x_or) / dnorm; skip_point.y = (skip_point.y - y_or) / dnorm; skip_point.z = (skip_point.z - z_or) / dnorm; } n1 = n_points + 1; /* C C GENERATION OF MATRIX C C FIRST COLUMN C */ A[1] = 0.; for (k = 1; k <= n_points; k++) { i1 = k + 1; A[i1] = 1.; } /* C C OTHER COLUMNS C */ RO = rsm; for (k = 1; k <= n_points; k++) { k1 = k * n1 + 1; k2 = k + 1; i1 = k1 + k; if (rsm < 0.) { /*indicates variable smoothing */ A[i1] = points[k - 1].sm; } else { A[i1] = RO; /* constant smoothing */ } for (l = k2; l <= n_points; l++) { xx = points[k - 1].x - points[l - 1].x; yy = points[k - 1].y - points[l - 1].y; zz = points[k - 1].z - points[l - 1].z; r = sqrt(xx * xx + yy * yy + zz * zz); etar = (fi * r) / 2.; if (etar == 0.) { /* printf ("ident. points in segm. \n"); printf ("x[%d]=%lf,x[%d]=%lf,y[%d]=%lf,y[%d]=%lf\n", k - 1, points[k - 1].x, l - 1, points[l - 1].x, k - 1, points[k - 1].y, l - 1, points[l - 1].y); */ } i1 = k1 + l; A[i1] = crs(etar); } } /* C C SYMMETRISATION C */ amaxa = 1.; for (k = 1; k <= n1; k++) { k1 = (k - 1) * n1; k2 = k + 1; for (l = k2; l <= n1; l++) { m = (l - 1) * n1 + k; A[m] = A[k1 + l]; amaxa = amax1(A[m], amaxa); } } /* C RIGHT SIDE C */ n4 = n1 * n1 + 1; A[n4] = 0.; for (l = 1; l <= n_points; l++) { l1 = n4 + l; A[l1] = points[l - 1].w; } n5 = n1 * (n1 + 1); for (i = 1; i <= n5; i++) A[i] = A[i] / amaxa; /* SOLVING OF SYSTEM */ if (LINEQS(n1, n1, 1, &NERROR, &DETERM)) { for (k = 1; k <= n_points; k++) { l = n4 + k; b[k] = A[l]; } b[n_points + 1] = A[n4]; POINT(n_points, points, skip_point); if (cv) return 1; if (devi != NULL && sig1 == 1) return 1; /* C C INTERPOLATION * MOST INNER LOOPS ! C */ NGST = 1; LSIZE = 0; ngstc = (int)(x_or / ew_res + 0.5) + 1; nszc = ngstc + n_cols - 1; ngstr = (int)(y_or / ns_res + 0.5) + 1; nszr = ngstr + n_rows - 1; ngstl = (int)(z_or / tb_res + 0.5) + 1; nszl = ngstl + n_levs - 1; /* fprintf(stderr," Progress percentage for each segment ..." ); */ /*fprintf(stderr,"Before loops,ngstl = %d,nszl =%d\n",ngstl,nszl); */ for (i = ngstl; i <= nszl; i++) { /*fprintf(stderr,"level=%d\n",i); */ /* G_percent(i, nszl, 2); */ offset = offset1 * (i - 1); /* levels offset */ zg = (i - ngstl) * stepiz; for (m = 1; m <= n_points; m++) { wz = zg - points[m - 1].z; wz1[m] = wz; wz2[m] = wz * wz; } for (k = ngstr; k <= nszr; k++) { yg = (k - ngstr) * stepiy; for (m = 1; m <= n_points; m++) { wm = yg - points[m - 1].y; w[m] = wm; w2[m] = wm * wm; } if ((cellinp != NULL) && (cellout != NULL) && (i == ngstl)) Rast_get_f_row(fdcell, cell, n_rows_in - k); for (l = ngstc; l <= nszc; l++) { LSIZE = LSIZE + 1; if (maskmap != NULL) bmask = BM_get(bitmask, l - 1, k - 1); /*bug fix 02/03/00 jh */ xg = (l - ngstc) * stepix; ww = 0.; wwcell = 0.; dx = 0.; dy = 0.; dz = 0.; dxx = 0.; dxy = 0.; dxz = 0.; dyy = 0.; dyz = 0.; dzz = 0.; /* compute everything for area which is not masked out and where cross_input map doesn't have nulls */ if (bmask == 1 && !(cell && Rast_is_f_null_value(&cell[l - 1]))) { h = b[n1]; hcell = b[n1]; for (m = 1; m <= n_points; m++) { xx = xg - points[m - 1].x; xx2 = xx * xx; if ((cellinp != NULL) && (cellout != NULL) && (i == ngstl)) { zcon = (double)(cell[l - 1] * zmult - z_or) - z_orig_in * zmult; /* bug fix 02/03/00 jh */ zcon = zcon / dnorm; zzcell = zcon - points[m - 1].z; zzcell2 = zzcell * zzcell; rcell = sqrt(xx2 + w2[m] + zzcell2); etarcell = (fi * rcell) / 2.; hcell = hcell + b[m] * crs(etarcell); } r2 = xx2 + w2[m] + wz2[m]; r = sqrt(r2); etar = (fi * r) / 2.; crs_full( etar,fi, &x_crs, cond1?&x_crsd:NULL, cond2?&x_crsdr2:NULL, cond2?&x_crsdd:NULL ); h = h + b[m] * x_crs; if(cond1) { bmgd1 = b[m] * x_crsd; dx = dx + bmgd1 * xx; dy = dy + bmgd1 * w[m]; dz = dz + bmgd1 * wz1[m]; } if(cond2) { bmgd2 = b[m] * x_crsdd; bmgd1 = b[m] * x_crsdr2; dyy = dyy + bmgd2 * w2[m] + bmgd1 * w2[m]; dzz = dzz + bmgd2 * wz2[m] + bmgd1 * wz2[m]; dxy = dxy + bmgd2 * xx * w[m] + bmgd1 * xx * w[m]; dxz = dxz + bmgd2 * xx * wz1[m] + bmgd1 * xx * wz1[m]; dyz = dyz + bmgd2 * w[m] * wz1[m] + bmgd1 * w[m] * wz1[m]; } } ww = h + wmin; if ((cellinp != NULL) && (cellout != NULL) && (i == ngstl)) wwcell = hcell + wmin; az[l] = ww; if (first_time_z) { first_time_z = 0; zmaxac = zminac = ww; if ((cellinp != NULL) && (cellout != NULL) && (i == ngstl)) zmaxacell = zminacell = wwcell; } zmaxac = amax1(ww, zmaxac); zminac = amin1(ww, zminac); if ((cellinp != NULL) && (cellout != NULL) && (i == ngstl)) { zmaxacell = amax1(wwcell, zmaxacell); zminacell = amin1(wwcell, zminacell); } if ((ww > wmax + 0.1 * (wmax - wmin)) || (ww < wmin - 0.1 * (wmax - wmin))) { static int once = 0; if (!once) { once = 1; fprintf(stderr, "WARNING:\n"); fprintf(stderr, "Overshoot -- increase in tension suggested.\n"); fprintf(stderr, "Overshoot occurs at (%d,%d,%d) cell\n", l, k, i); fprintf(stderr, "The w-value is %lf, wmin is %lf,wmax is %lf\n", ww, wmin, wmax); } } } /* skip here if you are in masked area, ww should be 0 */ az[l] = ww; adx[l] = dx; ady[l] = dy; adz[l] = dz; /* printf("\n %f", ww); */ adxx[l] = dxx; adxy[l] = dxy; adxz[l] = dxz; adyy[l] = dyy; adyz[l] = dyz; adzz[l] = dzz; if ((gradient != NULL) || (aspect1 != NULL) || (aspect2 != NULL) || (ncurv != NULL) || (gcurv != NULL) || (mcurv != NULL)) if (!(secpar_loop(ngstc, nszc, l))) { clean(); G_fatal_error(_("Secpar_loop failed")); } if ((cellinp != NULL) && (cellout != NULL) && (i == ngstl)) { zero_array_cell[l - 1] = (FCELL) (wwcell); } if (outz != NULL) { zero_array1[l - 1] = (float)(az[l] * sciz); } if (gradient != NULL) { zero_array2[l - 1] = (float)(adx[l]); } if (aspect1 != NULL) { zero_array3[l - 1] = (float)(ady[l]); } if (aspect2 != NULL) { zero_array4[l - 1] = (float)(adz[l]); } if (ncurv != NULL) { zero_array5[l - 1] = (float)(adxx[l]); } if (gcurv != NULL) { zero_array6[l - 1] = (float)(adyy[l]); } if (mcurv != NULL) { zero_array7[l - 1] = (float)(adxy[l]); } } /* columns */ ind = nsizc * (k - 1) + (ngstc - 1); ind1 = ngstc - 1; offset2 = offset + ind; /* rows*cols offset */ if ((cellinp != NULL) && (cellout != NULL) && (i == ngstl)) { G_fseek(Tmp_fd_cell, ((off_t)ind * sizeof(FCELL)), 0); if (! (fwrite (zero_array_cell + ind1, sizeof(FCELL), nszc - ngstc + 1, Tmp_fd_cell))) { clean(); G_fatal_error (_("Not enough disk space--cannot write files")); } } if (outz != NULL) { G_fseek(Tmp_fd_z, (off_t)(offset2 * sizeof(float)), 0); if (! (fwrite (zero_array1 + ind1, sizeof(float), nszc - ngstc + 1, Tmp_fd_z))) { clean(); G_fatal_error (_("Not enough disk space--cannot write files")); } } if (gradient != NULL) { G_fseek(Tmp_fd_dx, (off_t)(offset2 * sizeof(float)), 0); if (! (fwrite (zero_array2 + ind1, sizeof(float), nszc - ngstc + 1, Tmp_fd_dx))) { clean(); G_fatal_error (_("Not enough disk space--cannot write files")); } } if (aspect1 != NULL) { G_fseek(Tmp_fd_dy, (off_t)(offset2 * sizeof(float)), 0); if (! (fwrite (zero_array3 + ind1, sizeof(float), nszc - ngstc + 1, Tmp_fd_dy))) { clean(); G_fatal_error (_("Not enough disk space--cannot write files")); } } if (aspect2 != NULL) { G_fseek(Tmp_fd_dz, (off_t)(offset2 * sizeof(float)), 0); if (! (fwrite (zero_array4 + ind1, sizeof(float), nszc - ngstc + 1, Tmp_fd_dz))) { clean(); G_fatal_error (_("Not enough disk space--cannot write files")); } } if (ncurv != NULL) { G_fseek(Tmp_fd_xx, (off_t)(offset2 * sizeof(float)), 0); if (! (fwrite (zero_array5 + ind1, sizeof(float), nszc - ngstc + 1, Tmp_fd_xx))) { clean(); G_fatal_error (_("Not enough disk space--cannot write files")); } } if (gcurv != NULL) { G_fseek(Tmp_fd_yy, (off_t)(offset2 * sizeof(float)), 0); if (! (fwrite (zero_array6 + ind1, sizeof(float), nszc - ngstc + 1, Tmp_fd_yy))) { clean(); G_fatal_error (_("Not enough disk space--cannot write files")); } } if (mcurv != NULL) { G_fseek(Tmp_fd_xy, (off_t)(offset2 * sizeof(float)), 0); if (! (fwrite (zero_array7 + ind1, sizeof(float), nszc - ngstc + 1, Tmp_fd_xy))) { clean(); G_fatal_error (_("Not enough disk space--cannot write files")); } } } } } /* falls here if LINEQS() returns 0 */ /* total++; */ /*fprintf(stderr,"wminac=%lf,wmaxac=%lf\n",zminac,zmaxac); */ return 1; }
bool QgsWFSProvider::addFeatures( QgsFeatureList &flist ) { //create <Transaction> xml QDomDocument transactionDoc; QDomElement transactionElem = createTransactionElement( transactionDoc ); transactionDoc.appendChild( transactionElem ); //find out typename from uri and strip namespace prefix QString tname = mShared->mURI.typeName(); if ( tname.isNull() ) { return false; } removeNamespacePrefix( tname ); //Add the features QgsFeatureList::iterator featureIt = flist.begin(); for ( ; featureIt != flist.end(); ++featureIt ) { //Insert element QDomElement insertElem = transactionDoc.createElementNS( QgsWFSConstants::WFS_NAMESPACE, "Insert" ); transactionElem.appendChild( insertElem ); QDomElement featureElem = transactionDoc.createElementNS( mApplicationNamespace, tname ); QgsAttributes featureAttributes = featureIt->attributes(); int nAttrs = featureAttributes.size(); for ( int i = 0; i < nAttrs; ++i ) { const QVariant& value = featureAttributes.at( i ); if ( value.isValid() && !value.isNull() ) { QDomElement fieldElem = transactionDoc.createElementNS( mApplicationNamespace, mShared->mFields.at( i ).name() ); QDomText fieldText = transactionDoc.createTextNode( value.toString() ); fieldElem.appendChild( fieldText ); featureElem.appendChild( fieldElem ); } } //add geometry column (as gml) const QgsGeometry* geometry = featureIt->constGeometry(); if ( geometry != nullptr ) { QDomElement geomElem = transactionDoc.createElementNS( mApplicationNamespace, mShared->mGeometryAttribute ); QgsGeometry the_geom( *geometry ); // convert to multi if the layer geom type is multi and the geom is not if ( QGis::isMultiType( this->geometryType( ) ) && ! the_geom.isMultipart( ) ) { the_geom.convertToMultiType(); } QDomElement gmlElem = QgsOgcUtils::geometryToGML( &the_geom, transactionDoc ); if ( !gmlElem.isNull() ) { gmlElem.setAttribute( "srsName", crs().authid() ); geomElem.appendChild( gmlElem ); featureElem.appendChild( geomElem ); } } insertElem.appendChild( featureElem ); } QDomDocument serverResponse; bool success = sendTransactionDocument( transactionDoc, serverResponse ); if ( !success ) { return false; } if ( transactionSuccess( serverResponse ) ) { //transaction successful. Add the features to the cache QStringList idList = insertedFeatureIds( serverResponse ); QStringList::const_iterator idIt = idList.constBegin(); featureIt = flist.begin(); QVector<QgsWFSFeatureGmlIdPair> serializedFeatureList; for ( ; idIt != idList.constEnd() && featureIt != flist.end(); ++idIt, ++featureIt ) { serializedFeatureList.push_back( QgsWFSFeatureGmlIdPair( *featureIt, *idIt ) ); } mShared->serializeFeatures( serializedFeatureList ); // And now set the feature id from the one got from the database QMap< QString, QgsFeatureId > map; for ( int idx = 0; idx < serializedFeatureList.size(); idx++ ) map[ serializedFeatureList[idx].second ] = serializedFeatureList[idx].first.id(); idIt = idList.constBegin(); featureIt = flist.begin(); for ( ; idIt != idList.constEnd() && featureIt != flist.end(); ++idIt, ++featureIt ) { if ( map.find( *idIt ) != map.end() ) featureIt->setFeatureId( map[*idIt] ); } return true; } else { handleException( serverResponse ); return false; } }
bool QgsWFSProvider::changeGeometryValues( const QgsGeometryMap &geometry_map ) { //find out typename from uri and strip namespace prefix QString tname = mShared->mURI.typeName(); if ( tname.isNull() ) { return false; } //create <Transaction> xml QDomDocument transactionDoc; QDomElement transactionElem = createTransactionElement( transactionDoc ); transactionDoc.appendChild( transactionElem ); QgsGeometryMap::const_iterator geomIt = geometry_map.constBegin(); for ( ; geomIt != geometry_map.constEnd(); ++geomIt ) { QString gmlid = mShared->findGmlId( geomIt.key() ); if ( gmlid.isEmpty() ) { QgsDebugMsg( QString( "Cannot identify feature of id %1" ).arg( geomIt.key() ) ); continue; } QDomElement updateElem = transactionDoc.createElementNS( QgsWFSConstants::WFS_NAMESPACE, "Update" ); updateElem.setAttribute( "typeName", tname ); //Property QDomElement propertyElem = transactionDoc.createElementNS( QgsWFSConstants::WFS_NAMESPACE, "Property" ); QDomElement nameElem = transactionDoc.createElementNS( QgsWFSConstants::WFS_NAMESPACE, "Name" ); QDomText nameText = transactionDoc.createTextNode( mShared->mGeometryAttribute ); nameElem.appendChild( nameText ); propertyElem.appendChild( nameElem ); QDomElement valueElem = transactionDoc.createElementNS( QgsWFSConstants::WFS_NAMESPACE, "Value" ); QDomElement gmlElem = QgsOgcUtils::geometryToGML( &geomIt.value(), transactionDoc ); gmlElem.setAttribute( "srsName", crs().authid() ); valueElem.appendChild( gmlElem ); propertyElem.appendChild( valueElem ); updateElem.appendChild( propertyElem ); //filter QDomElement filterElem = transactionDoc.createElementNS( QgsWFSConstants::OGC_NAMESPACE, "Filter" ); QDomElement featureIdElem = transactionDoc.createElementNS( QgsWFSConstants::OGC_NAMESPACE, "FeatureId" ); featureIdElem.setAttribute( "fid", gmlid ); filterElem.appendChild( featureIdElem ); updateElem.appendChild( filterElem ); transactionElem.appendChild( updateElem ); } QDomDocument serverResponse; bool success = sendTransactionDocument( transactionDoc, serverResponse ); if ( !success ) { return false; } if ( transactionSuccess( serverResponse ) ) { mShared->changeGeometryValues( geometry_map ); return true; } else { handleException( serverResponse ); return false; } }
float Vector2::angle(float x, float y) { return (float)atan2(crs(x, y), dot(x, y)) * MathUtils::radiansToDegrees; }
float Vector2::crs(cocos2d::Vec2 val) { return crs(val.x, val.y); }
float Vector2::angleRad(float x, float y) { return (float)atan2(crs(x, y), dot(x, y)); }