コード例 #1
0
//---------------------------------------------------------
bool CPointCloud_From_Text_File::Get_Data_Type(TSG_Data_Type &Type, const CSG_String &Value)
{
	int	iType;

	if( Value.asInt(iType) )
	{
		switch( iType )
		{
		case  0: Type = SG_DATATYPE_Char  ; return( true );
		case  1: Type = SG_DATATYPE_Short ; return( true );
		case  2: Type = SG_DATATYPE_Int   ; return( true );
		case  3: Type = SG_DATATYPE_Float ; return( true );
		case  4: Type = SG_DATATYPE_Double; return( true );
		case  5: Type = SG_DATATYPE_String; return( true );
		}
	}

	if( !Value.CmpNoCase("char"  ) ) { Type = SG_DATATYPE_Char  ; return( true ); }
	if( !Value.CmpNoCase("short" ) ) { Type = SG_DATATYPE_Short ; return( true ); }
	if( !Value.CmpNoCase("int"   ) ) { Type = SG_DATATYPE_Int   ; return( true ); }
	if( !Value.CmpNoCase("float" ) ) { Type = SG_DATATYPE_Float ; return( true ); }
	if( !Value.CmpNoCase("double") ) { Type = SG_DATATYPE_Double; return( true ); }
	if( !Value.CmpNoCase("string") ) { Type = SG_DATATYPE_String; return( true ); }

	return( false );
}
コード例 #2
0
//---------------------------------------------------------
int CSG_MetaData::_Get_Property(const CSG_String &Name) const
{
	for(int i=0; i<m_Prop_Names.Get_Count(); i++)
	{
		if( Name.CmpNoCase(m_Prop_Names[i]) == 0 )
		{
			return( i );
		}
	}

	return( -1 );
}
コード例 #3
0
//---------------------------------------------------------
int CSG_MetaData::_Get_Child(const CSG_String &Name) const
{
	for(int i=0; i<Get_Children_Count(); i++)
	{
		if( Name.CmpNoCase(Get_Child(i)->Get_Name()) == 0 )
		{
			return( i );
		}
	}

	return( -1 );
}
コード例 #4
0
ファイル: metadata.cpp プロジェクト: am2222/SAGA-GIS
//---------------------------------------------------------
int CSG_MetaData::_Get_Child(const CSG_String &Name) const
{
	for(int i=0; i<m_nChildren; i++)
	{
		if( Name.CmpNoCase(m_pChildren[i]->Get_Name()) == 0 )
		{
			return( i );
		}
	}

	return( -1 );
}
コード例 #5
0
ファイル: shapes_ogis.cpp プロジェクト: johanvdw/saga-debian
//---------------------------------------------------------
bool CSG_Shapes_OGIS_Converter::from_WKText(const CSG_String &Text, CSG_Shape *pShape)
{
	pShape->Del_Parts();

	CSG_String	Type	= Text.BeforeFirst('(');

	Type.Trim(true);
	Type.Trim(false);

	switch( pShape->Get_Type() )
	{
	case SHAPE_TYPE_Point:
		if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_Point) )
		{
			return( _WKT_Read_Point(Text.AfterFirst('(').BeforeFirst(')'), pShape, 0) );
		}
		break;

	case SHAPE_TYPE_Points:
		if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_MultiPoint) )
		{
			return( _WKT_Read_Parts(Text, pShape) );
		}
		break;

	case SHAPE_TYPE_Line:
		if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_Line) )
		{
			return( _WKT_Read_Points(Text, pShape) );
		}

		if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_MultiLine) )
		{
			return( _WKT_Read_Parts(Text, pShape) );
		}
		break;

	case SHAPE_TYPE_Polygon:
		if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_Polygon) )
		{
			return( _WKT_Read_Parts(Text, pShape) );
		}

		if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_MultiPolygon) )
		{
			return( _WKT_Read_Polygon(Text, pShape) );
		}
		break;
	default:
		break;
	  
	}

	return( false );
}
コード例 #6
0
//---------------------------------------------------------
CSG_ODBC_Connection::CSG_ODBC_Connection(const CSG_String &Server, const CSG_String &User, const CSG_String &Password, bool bAutoCommit)
{
	CSG_String	s;

	m_DBMS			= SG_ODBC_DBMS_Unknown;
	m_Size_Buffer	= 1;
	m_bAutoCommit	= bAutoCommit;

	if( User.Length() > 0 )
	{
		s	+= SG_T("UID=") + User     + SG_T(";");
		s	+= SG_T("PWD=") + Password + SG_T(";");
	}

	s	+= SG_T("DSN=") + Server   + SG_T(";");

	m_pConnection	= new otl_connect();

	try
	{
		m_Connection.rlogon(s, m_bAutoCommit ? 1 : 0);
	}
	catch( otl_exception &e )
	{
		_Error_Message(e);
	}

	//-----------------------------------------------------
	if( !m_Connection.connected )
	{
		delete(((otl_connect *)m_pConnection));

		m_pConnection	= NULL;
	}
	else
	{
		m_DSN	= Server;

		//-------------------------------------------------
		s		= Get_DBMS_Name();

		if(      !s.CmpNoCase(SG_T("PostgreSQL")) )
		{
			m_DBMS	= SG_ODBC_DBMS_PostgreSQL;
		}
		else if( !s.CmpNoCase(SG_T("MySQL")) )
		{
			m_DBMS	= SG_ODBC_DBMS_MySQL;
		}
		else if( !s.CmpNoCase(SG_T("Oracle")) )
		{
			m_DBMS	= SG_ODBC_DBMS_Oracle;
		}
		else if( !s.CmpNoCase(SG_T("MSQL")) )
		{
			m_DBMS	= SG_ODBC_DBMS_MSSQLServer;
		}
		else if( !s.CmpNoCase(SG_T("ACCESS")) )
		{
			m_DBMS	= SG_ODBC_DBMS_Access;
		}

		//-------------------------------------------------
		Set_Size_Buffer(is_Access() ? 1 : 50);

		Set_Size_LOB_Max(4 * 32767);
	}
}
コード例 #7
0
ファイル: shapes_ogis.cpp プロジェクト: johanvdw/saga-debian
//---------------------------------------------------------
bool CSG_Shapes_OGIS_Converter::to_ShapeType(const CSG_String &Type, TSG_Shape_Type &Shape, TSG_Vertex_Type &Vertex)
{
	if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_Point           ) )	{	Shape	= SHAPE_TYPE_Point;		Vertex	= SG_VERTEX_TYPE_XY;	return( true );	}
	if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_MultiPoint      ) )	{	Shape	= SHAPE_TYPE_Points;	Vertex	= SG_VERTEX_TYPE_XY;	return( true );	}
	if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_Line            ) )	{	Shape	= SHAPE_TYPE_Line;		Vertex	= SG_VERTEX_TYPE_XY;	return( true );	}
	if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_MultiLine       ) )	{	Shape	= SHAPE_TYPE_Line;		Vertex	= SG_VERTEX_TYPE_XY;	return( true );	}
	if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_Polygon         ) )	{	Shape	= SHAPE_TYPE_Polygon;	Vertex	= SG_VERTEX_TYPE_XY;	return( true );	}
	if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_MultiPolygon    ) )	{	Shape	= SHAPE_TYPE_Polygon;	Vertex	= SG_VERTEX_TYPE_XY;	return( true );	}

	if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_Point_Z         ) )	{	Shape	= SHAPE_TYPE_Point;		Vertex	= SG_VERTEX_TYPE_XYZ;	return( true );	}
	if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_MultiPoint_Z    ) )	{	Shape	= SHAPE_TYPE_Points;	Vertex	= SG_VERTEX_TYPE_XYZ;	return( true );	}
	if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_Line_Z          ) )	{	Shape	= SHAPE_TYPE_Line;		Vertex	= SG_VERTEX_TYPE_XYZ;	return( true );	}
	if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_MultiLine_Z     ) )	{	Shape	= SHAPE_TYPE_Line;		Vertex	= SG_VERTEX_TYPE_XYZ;	return( true );	}
	if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_Polygon_Z       ) )	{	Shape	= SHAPE_TYPE_Polygon;	Vertex	= SG_VERTEX_TYPE_XYZ;	return( true );	}
	if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_MultiPolygon_Z  ) )	{	Shape	= SHAPE_TYPE_Polygon;	Vertex	= SG_VERTEX_TYPE_XYZ;	return( true );	}

	if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_Point_M         ) )	{	Shape	= SHAPE_TYPE_Point;		Vertex	= SG_VERTEX_TYPE_XYZ;	return( true );	}
	if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_MultiPoint_M    ) )	{	Shape	= SHAPE_TYPE_Points;	Vertex	= SG_VERTEX_TYPE_XYZ;	return( true );	}
	if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_Line_M          ) )	{	Shape	= SHAPE_TYPE_Line;		Vertex	= SG_VERTEX_TYPE_XYZ;	return( true );	}
	if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_MultiLine_M     ) )	{	Shape	= SHAPE_TYPE_Line;		Vertex	= SG_VERTEX_TYPE_XYZ;	return( true );	}
	if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_Polygon_M       ) )	{	Shape	= SHAPE_TYPE_Polygon;	Vertex	= SG_VERTEX_TYPE_XYZ;	return( true );	}
	if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_MultiPolygon_M  ) )	{	Shape	= SHAPE_TYPE_Polygon;	Vertex	= SG_VERTEX_TYPE_XYZ;	return( true );	}

	if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_Point_ZM        ) )	{	Shape	= SHAPE_TYPE_Point;		Vertex	= SG_VERTEX_TYPE_XYZM;	return( true );	}
	if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_MultiPoint_ZM   ) )	{	Shape	= SHAPE_TYPE_Points;	Vertex	= SG_VERTEX_TYPE_XYZM;	return( true );	}
	if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_Line_ZM         ) )	{	Shape	= SHAPE_TYPE_Line;		Vertex	= SG_VERTEX_TYPE_XYZM;	return( true );	}
	if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_MultiLine_ZM    ) )	{	Shape	= SHAPE_TYPE_Line;		Vertex	= SG_VERTEX_TYPE_XYZM;	return( true );	}
	if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_Polygon_ZM      ) )	{	Shape	= SHAPE_TYPE_Polygon;	Vertex	= SG_VERTEX_TYPE_XYZM;	return( true );	}
	if( !Type.CmpNoCase(SG_OGIS_TYPE_STR_MultiPolygon_ZM ) )	{	Shape	= SHAPE_TYPE_Polygon;	Vertex	= SG_VERTEX_TYPE_XYZM;	return( true );	}

	Shape	= SHAPE_TYPE_Undefined;

	return( false );
}
コード例 #8
0
//---------------------------------------------------------
bool CSG_MetaData::Cmp_Property(const CSG_String &Name, const CSG_String &String, bool bNoCase) const
{
	CSG_String	s;

	return( Get_Property(Name, s) && (bNoCase ? !s.CmpNoCase(String) : !s.Cmp(String)) );
}
コード例 #9
0
//---------------------------------------------------------
bool CPointCloud_Create_Tileshape_From_SPCVF::On_Execute(void)
{
	CSG_String		sFileName;
	CSG_Shapes		*pShapes;

	CSG_MetaData	SPCVF;
	CSG_String		sPathSPCVF, sFilePath;
	int				iPoints;
	double			dBBoxXMin, dBBoxYMin, dBBoxXMax, dBBoxYMax;


	//-----------------------------------------------------
	sFileName	= Parameters("FILENAME")->asString();
	pShapes		= Parameters("TILE_SHP")->asShapes();
	

	//-----------------------------------------------------
	if( !SPCVF.Create(sFileName) || SPCVF.Get_Name().CmpNoCase(SG_T("SPCVFDataset")) )
	{
		SG_UI_Msg_Add_Error(_TL("Please provide a valid *.scpvf file!"));
		return( false );
	}


	//-----------------------------------------------------
	CSG_String	sMethodPaths;
	SPCVF.Get_Property(SG_T("Paths"), sMethodPaths);

	if( !sMethodPaths.CmpNoCase(SG_T("absolute")) )
	{
		sPathSPCVF = SG_T("");
	}
	else if( !sMethodPaths.CmpNoCase(SG_T("relative")) )
	{
		sPathSPCVF = SG_File_Get_Path(sFileName);
		sPathSPCVF.Replace(SG_T("\\"), SG_T("/"));
	}
	else
	{
		SG_UI_Msg_Add_Error(_TL("Encountered invalid path description in *.spcvf file!"));
		return( false );
	}


	//-----------------------------------------------------
	pShapes->Destroy();

	pShapes->Add_Field(_TL("ID"),		SG_DATATYPE_Int);
	pShapes->Add_Field(_TL("Filepath"),	SG_DATATYPE_String);
	pShapes->Add_Field(_TL("File"),		SG_DATATYPE_String);
	pShapes->Add_Field(_TL("Points"),	SG_DATATYPE_Int);

	pShapes->Set_Name(CSG_String::Format(_TL("Tileshape_%s"), SG_File_Get_Name(sFileName, false).c_str()));


	//-----------------------------------------------------
	CSG_MetaData	*pDatasets = SPCVF.Get_Child(SG_T("Datasets"));

	for(int i=0; i<pDatasets->Get_Children_Count(); i++)
	{
		CSG_MetaData	*pDataset	= pDatasets->Get_Child(i);
		CSG_MetaData	*pBBox		= pDataset->Get_Child(SG_T("BBox"));

		pDataset->Get_Property(SG_T("File"), sFilePath);

		pDataset->Get_Property(SG_T("Points"), iPoints);

		pBBox->Get_Property(SG_T("XMin"), dBBoxXMin);
		pBBox->Get_Property(SG_T("YMin"), dBBoxYMin);
		pBBox->Get_Property(SG_T("XMax"), dBBoxXMax);
		pBBox->Get_Property(SG_T("YMax"), dBBoxYMax);

		//-----------------------------------------------------
		CSG_Shape	*pShape = pShapes->Add_Shape();

		pShape->Add_Point(dBBoxXMin, dBBoxYMin);
		pShape->Add_Point(dBBoxXMin, dBBoxYMax);
		pShape->Add_Point(dBBoxXMax, dBBoxYMax);
		pShape->Add_Point(dBBoxXMax, dBBoxYMin);

		pShape->Set_Value(0, i + 1);

		if( sPathSPCVF.Length() == 0 )	// absolute paths
		{
			pShape->Set_Value(1, sFilePath.BeforeLast('/'));
			pShape->Set_Value(2, sFilePath.AfterLast('/'));
		}
		else							// relative paths
		{
			pShape->Set_Value(1, sPathSPCVF);
			pShape->Set_Value(2, sFilePath);
		}

		pShape->Set_Value(3, iPoints);
	}


	//-----------------------------------------------------
	return( true );
}
コード例 #10
0
//---------------------------------------------------------
bool CPC_Merge::On_Execute(void)
{
	CSG_PointCloud		*pMain, *pAdd, *pResult;
	bool				bID;
	int					iStartValue;
	int					iAccept = 0;

	CSG_Parameter_PointCloud_List	*pPointCloudList;
	std::vector<CSG_String>			FieldNames;
	std::vector<TSG_Data_Type>		FieldTypes;


	pMain				= Parameters("PC_IN")->asPointCloud();
	pPointCloudList		= Parameters("PC_LAYERS")->asPointCloudList();
	pResult				= Parameters("PC_OUT")->asPointCloud();
	bID					= Parameters("ADD_IDENTIFIER")->asBool();
	iStartValue			= Parameters("START_VALUE")->asInt();

	pResult->Create(pMain);
	pResult->Set_Name(CSG_String::Format(_TL("%s_merged"), pMain->Get_Name()));
	if( bID )
		pResult->Add_Field(SG_T("ID"), SG_DATATYPE_Int);
	DataObject_Update(pResult);


	//copy main layer into destination
	for(int iField=0; iField<pMain->Get_Attribute_Count(); iField++)
	{
		FieldNames.push_back(pMain->Get_Attribute_Name(iField));
		FieldTypes.push_back(pMain->Get_Attribute_Type(iField));
	}

	for(int i=0; i<pMain->Get_Count() && Set_Progress(i, pMain->Get_Count()); i++)
	{
		pResult->Add_Point(pMain->Get_X(i), pMain->Get_Y(i), pMain->Get_Z(i));

		for(int iField=0; iField<pMain->Get_Attribute_Count(); iField++)
		{
			pResult->Set_Attribute(iAccept, iField, pMain->Get_Attribute(i, iField));
		}

		if( bID )
			pResult->Set_Attribute(iAccept, pMain->Get_Attribute_Count(), iStartValue);

		iAccept++;	
	}


	//copy additional layer into destination
	if( (pPointCloudList = Parameters("PC_LAYERS")->asPointCloudList()) != NULL && pPointCloudList->Get_Count() > 0 )
	{
		for(int iLayer=0; iLayer<pPointCloudList->Get_Count(); iLayer++)
		{
			if( (pAdd = pPointCloudList->asPointCloud(iLayer)) != NULL )
			{
				if( pAdd->Get_Type() == pMain->Get_Type() )
				{
					pAdd = pPointCloudList->asPointCloud(iLayer);

					std::vector<int>	FieldMapping(FieldNames.size(), -1);	// pMain to pAdd

					for(int iField=0; iField<pAdd->Get_Attribute_Count(); iField++)
					{
						CSG_String ThisField = pAdd->Get_Attribute_Name(iField);

						for(int j=0; j<FieldNames.size(); j++)
						{	
							if( !ThisField.CmpNoCase(FieldNames[j]) )
							{
								if( pAdd->Get_Attribute_Type(iField) == FieldTypes[j] )
								{
									FieldMapping[j] = iField;
									break;
								}
							}
						}
					}

					for(int i=0; i<pAdd->Get_Count() && Set_Progress(i, pAdd->Get_Count()); i++)
					{
						pResult->Add_Point(pAdd->Get_X(i), pAdd->Get_Y(i), pAdd->Get_Z(i));

						for(int iField=0; iField<pMain->Get_Attribute_Count(); iField++)
						{
							if( FieldMapping[iField] > -1 )
								pResult->Set_Attribute(iAccept, iField, pAdd->Get_Attribute(i, FieldMapping[iField]));
							else
								pResult->Set_Attribute(iAccept, iField, pMain->Get_NoData_Value());
						}

						if( bID )
						{
							pResult->Set_Attribute(iAccept, pMain->Get_Attribute_Count(), iLayer + iStartValue + 1);
						}

						iAccept++;
					}
				}
			}
		}
	}


	CSG_Parameters	sParms;
	DataObject_Get_Parameters(pResult, sParms);
	
	if( sParms("METRIC_ATTRIB")	&& sParms("COLORS_TYPE") && sParms("METRIC_COLORS")
		&& sParms("METRIC_ZRANGE") && sParms("DISPLAY_VALUE_AGGREGATE") )
	{
		sParms("DISPLAY_VALUE_AGGREGATE")		->Set_Value(3);
		sParms("COLORS_TYPE")					->Set_Value(2);
		sParms("METRIC_COLORS")->asColors()		->Set_Count(255);
		sParms("METRIC_ATTRIB")					->Set_Value(2);
		sParms("METRIC_ZRANGE")->asRange()		->Set_Range(pResult->Get_Minimum(2), pResult->Get_Maximum(2));
	}

	DataObject_Set_Parameters(pResult, sParms);
	DataObject_Update(pResult);

	return( true );
}